Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the order of components in rePCA the same as the order of random effects in lme4? #11

Open
hikea opened this issue Sep 20, 2019 · 0 comments

Comments

@hikea
Copy link

hikea commented Sep 20, 2019

We run two models with the only difference of the order of random effects (Trial is the last in the first model, while it is the first in the second model)

library(languageR)
lexdec = lexdec

lexdec_model1 <- lmer(RT ~ Class+NativeLanguage+Frequency+scale(Trial) + (1+Class+Frequency+scale(Trial)|Subject) + (1|Word), data=lexdec)
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 1 negative eigenvalues


lexdec_model2 <- lmer(RT ~ Class+NativeLanguage+Frequency+scale(Trial) + (1+scale(Trial)+Class+Frequency|Subject) + (1|Word), data=lexdec)

Now, the fact that the first one fails while the second one doesn't is an issue in itself, but let's disregard it for the moment. It is under review by @bbolker here https://github.com/lme4/lme4/issues/449

The question is what happens when I use rePCA? What is the order of random effects there?

library(RePsychLing)
> summary(rePCA(lexdec_model1))
$Word
Importance of components:
                         [,1]
Standard deviation     0.3082
Proportion of Variance 1.0000
Cumulative Proportion  1.0000

$Subject
Importance of components:
                         [,1]    [,2]    [,3]     [,4]
Standard deviation     1.4020 0.21921 0.17432 4.09e-18
Proportion of Variance 0.9616 0.02351 0.01487 0.00e+00
Cumulative Proportion  0.9616 0.98513 1.00000 1.00e+00

> summary(rePCA(lexdec_model2))
$Word
Importance of components:
                         [,1]
Standard deviation     0.3082
Proportion of Variance 1.0000
Cumulative Proportion  1.0000

$Subject
Importance of components:
                         [,1]    [,2]    [,3] [,4]
Standard deviation     1.4004 0.21913 0.17481    0
Proportion of Variance 0.9615 0.02354 0.01498    0
Cumulative Proportion  0.9615 0.98502 1.00000    1

First, note that the numbers don't change in rePCA output.
Second, it's clear that one of the components (listed last) accounts for 0% of the variance and can be removed, but which one, Trial or Frequency? (Note that the intercept (I assume it's the first component) accounts for 96% of the variance, so all random slopes can be removed, but this is just an example for illustration purposes, in my data set the situation is more complicated)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant