Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
predict vs fitted #403
Comments
|
Sorry, but there's no way we can answer this question without a reproducible example ... in a simple case, these values are indeed the same, e.g.
You have a rather complex random-effects structure, and in particular you have (implicitly) repeated intercept terms across all of your random effects. In principle this shouldn't mess up your predictions, but you should at least have seen a warning ...
|
|
I can reproduce it with this dataset.
|
|
Thanks @pitakakariki . I will dig into this. I will say, though, that I will be more diligent/enthusiastic if I can see some evidence that this also happens in a model that is not pathological ... |
JannieLee
commented
Dec 12, 2016
|
Thanks, @bbolker . I also got the same results, when I added random effects on onle one variable. But why does it not work with a rather complex random-effects structure? Thanks for your attention. |
|
Just a hunch but if the model hasn't converged, might |
|
@pitakakariki .. good hunch. I'd also guess something like that (there are more components of the fit object which could have not been completely updated). Do we have any example of a difference predict / fitted in a converged model? |
|
I think I've worked out what's happening. Have a look at There's a line in
which in this example translates roughly to e.g.
That's going to pick up the first column, whereas the "correct" column is the seventh in this case. |
|
|
great! I will see what I can do to fix this. (Nevertheless, it does confirm my suspicion that this will only happen in a weird situation, i.e. when we have redundant/confounded intercept terms) |
|
Is it possible to specify the same model but with a single identifiable intercept term --- i.e. a random intercept which is correlated with the random slopes for x1 through x7, but where the random slopes are uncorrelated? Or would that need flexLambda? |
|
You could hack this up with the modular structure. The most immediately sensible way to fix this is to specify the random effects as |
JannieLee
commented
Dec 13, 2016
|
Thanks, @bbolker, I think it works with the structure ((1|Subject) + (0+X1|Subject)+ (0+X2|Subject) + ...). |
skanskan
commented
Mar 10, 2017
|
Is it correct to have X1, X2....X7 in bot the fixed and the random side simultaneously? |
|
Yes. In fact it's generally necessary for a sensible model. I could have sworn I started to work on this problem, but I can't find any evidence thereof (e.g., a branch where I was working on a solution). |
skanskan
commented
Mar 11, 2017
|
Another example. Weight ~Age+(1|ID) Would it be right to express it as |
|
This isn't the right venue for this conversation; the issue list is for discussion of the software itself (bugs, wishlist, etc.), not general questions about mixed modeling or lme4's formula specifications. Could you please raise it on |
JannieLee commentedDec 11, 2016
Recently, I used this package to deal with the linear mixed effects model, however, I have got a problem as follows.
The f_fit are not same to f_pre (e.g., f_fit[1]=32.5, f_pre[1]=179.6), but why?