jknowles / merTools

Convenience functions for working with merMod objects from lme4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

returnSims = TRUE doesn't return simulations

svmiller opened this issue · comments

I hope I have this right, but, if I understand the documentation correctly, returnSims = TRUE should return all n.sims simulations. However, returnSims = TRUE seems to return the exact same data frame as returnSims = FALSE.

Reproducible example:

data(sleepstudy)
fm1 <- lmer(Reaction ~ Days + (Days|Subject), data=sleepstudy)
newdat <- head(sleepstudy, 15)
merTools::predictInterval(fm1, 
                          newdata=newdat, 
                          include.resid.var=F,
                          n.sims=100, 
                          returnSims = TRUE)

        fit      upr      lwr
1  254.4316 271.9048 238.4803
2  273.6816 289.2957 258.8978
3  293.5219 308.4534 281.0999
4  313.5256 326.3566 301.1072
5  334.5676 348.5486 321.4179
6  354.0708 370.4739 339.3475
7  373.4132 391.0570 356.6492
8  393.2969 412.5220 372.9423
9  412.6426 433.2870 389.8587
10 431.3545 454.5046 407.3736
11 211.1245 229.0705 192.0908
12 213.6821 229.7084 195.6777
13 214.9012 228.9158 197.7995
14 216.8578 231.9264 199.5900
15 218.5367 235.1615 203.8790

If I understand correctly, I should be getting a matrix back with 1500 rows, not 15.

I apologize for taking up everyone's time if I'm mistaken here.

Save the object and look at the attributes attached to the data.frame. You will find the simulations stored there. The documentation could perhaps be clearer that the simulations will be stored in an attribute of the data.frame, and not returned directly.