Giter Site home page Giter Site logo

Intercept-less models broken about afex HOT 4 CLOSED

singmann avatar singmann commented on August 17, 2024
Intercept-less models broken

from afex.

Comments (4)

singmann avatar singmann commented on August 17, 2024

The problem is that the model you want to fit has only one term, the variable:period interaction. There is no way mixed can test this interaction. Remember that mixed removes all the term in a stepwise manner and tests them against the remaining model. If the interaction is removed, the model has no more fixed effect so cannot be fitted. That is why one also cannot test a model with mixed that only has an intercept and not other terms (there remains no model to compare it with after removing the single term).

However, you can test a binomial model, by transforming the frequencies to a probability:

cbpp$prob <- with(cbpp, incidence / size)
m1p <- mixed(prob ~ period + (1 | herd), weights = size, family = binomial, data = cbpp, method = "LRT")
m1p
##   Effect df     Chisq p.value
## 1 period  3 25.61 ***  <.0001

from afex.

 avatar commented on August 17, 2024

OK, I agree that that was a particularly bad example of an intercept-less model. How about the below, though? (the model doesn't make any sense but just to use it as an example problem)

> mixed(Petal.Width ~ 0 + Sepal.Length + Sepal.Width + Petal.Length + (1|Species),iris)
Contrasts set to contr.sum for the following variables: Species
Numerical variables NOT centered on 0 (i.e., interpretation of all main effects might be difficult if in interactions): Sepal.Length, Sepal.Width, Petal.Length
Fitting 4 (g)lmer() models:
[.Error in x[, ii] : subscript out of bounds

Again, with the intercept, this model is fit just fine.

from afex.

singmann avatar singmann commented on August 17, 2024

Can you tell me what your goal is? I have the suspicion that the tests of the intercept less models are problematic and are not worth to implement.
You can fit binomial models with cbind(incidence,size) ~ period + (1|herd) by transforming the left side to a proportion and passing the number of observations via weights.

from afex.

 avatar commented on August 17, 2024

(sorry, accidentally posted this with another account, reposting:)

Of course. I have a lot of trials of EEG data (32 electrodes, 900-ms timeslices). I'm trying to determine which electrodes & at what timepoints I should be looking at to run my statistical analyses. This is normally done by running, at every timepoint, a multivariate ANOVA with 32 dependent variables, and plotting the resulting 32 * 900 (assuming for simplicity a sampling rate of 1ms) p-values in a heatmap (with 32 electrodes on the y axis, time on the x axis, p-value as the color). This helps you determine your time window and electrode subset on which you want to run your actual statistical analysis. Note that this method of running 32 * 900 F-tests has a huge multiple comparisons problem, which is dealt with by running a permutation equivalent of the ANOVA analysis.

What I want to do is see whether the results I obtain from this standard methodology will be different if I use mixed-effects models instead of ANOVAs (which cannot incorporate random effects). There is no permutation test for lmer models as far as I know, but a similar approach is available in parametric bootstrapping. This is what led me to afex::mixed. (I realize that using bootstrapping with my current approach will be prohibitively slow, but I can cluster some of the electrodes/bin my timepoints/etc.)

The problem then is that I want to somehow run a multivariate model (it's actually linear regression, the - poor - example above was simply the first freely-available multivariate dataset I could find, which happened to be binomial instead of gaussian only by coincidence). The cbind(electrode1,electrode2,... trick doesn't work with mixed, but neither does the workaround described in comment 1, viz. to melt my 32 dependent variables into a factor and using that as the first predictor in the model - even before the intercept. The latter seemed a more general problem than the former, hence why I reported that as a bug.

from afex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.