[R-sig-ME] Does lmer have it's own random number generator?

Douglas Bates bates at stat.wisc.edu
Mon Jan 3 13:27:03 CET 2011


On Mon, Jan 3, 2011 at 4:01 AM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be> wrote:
> Dear Mike,
>
> Are you sure? Below the results of 100 simulations. I get the same
> results each time.
>
> Best regards,
>
> Thierry
>
>> set.seed(1)
>> tmp <- replicate(100, {
> +       fit <- lmer(
> +               formula = rt ~ (1|subnum) +
> +                       cue*flank*group*block +
> +                       cue*flank*group*I(block^2) +
> +                       cue*flank*group*I(block^3)
> +               , data = ANT[ANT$error==0,]
> +       )
> +       fit at deviance
> + })
>> apply(tmp, 1, var)
>       ML      REML      ldL2     ldRX2   sigmaML sigmaREML     pwrss
> disc
>        0         0         0         0         0         0         0
> 0
>     usqr      wrss       dev      llik   NULLdev
>        0         0        NA        NA        NA
>> sessionInfo()
> R version 2.12.0 (2010-10-15)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=Dutch_Belgium.1252  LC_CTYPE=Dutch_Belgium.1252
> [3] LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C
> [5] LC_TIME=Dutch_Belgium.1252
>
> attached base packages:
>  [1] grid      grDevices datasets  splines   graphics  stats     tcltk
>
>  [8] utils     methods   base
>
> other attached packages:
>  [1] ez_2.1-0           lme4_0.999375-37   Matrix_0.999375-45
> lattice_0.19-15
>  [5] stringr_0.4        ggplot2_0.8.8      proto_0.3-8
> reshape_0.8.3
>  [9] plyr_1.2.1         car_2.0-7          nnet_7.3-1         MASS_7.3-7
>
> [13] rj_0.5.0-5         svSocket_0.9-51    TinnR_1.0.3        R2HTML_2.2
>
> [17] Hmisc_3.8-3        survival_2.36-1
>
> loaded via a namespace (and not attached):
> [1] cluster_1.13.2 nlme_3.1-97    rJava_0.8-8    stats4_2.12.0
> svMisc_0.9-61
> [6] tools_2.12.0
>
>
>> -----Oorspronkelijk bericht-----
>> Van: r-sig-mixed-models-bounces at r-project.org
>> [mailto:r-sig-mixed-models-bounces at r-project.org] Namens Mike Lawrence
>> Verzonden: maandag 3 januari 2011 3:52
>> Aan: r-sig-mixed-models at r-project.org
>> Onderwerp: [R-sig-ME] Does lmer have it's own random number generator?
>>
>> Hi folks,
>>
>> Does lmer have it's own internally seeded random number
>> generator? I just came across an example where I get
>> different results across repeated identically specified lmer
>> fits even when I use set.seed():
>>
>> library(ez)
>> data(ANT)
>>
>> #repeat the below a few times, the result # on the last line
>> should vary occasionally, # sometimes TRUE, sometimes FALSE,
>> # and sometimes there will be a warning # after the fit
>>
>> set.seed(1)
>> fit = lmer(
>>       formula = rt ~ (1|subnum) +
>>               cue*flank*group*block +
>>               cue*flank*group*I(block^2) +
>>               cue*flank*group*I(block^3)
>>       , data = ANT[ANT$error==0,]
>> )
>> any(is.finite(attr(fit,'deviance')))

A call to lmer does not, as far as I know, result in any calls to
random number generators.  There is only one point in the lme4 package
where set.seed is called and that is in the simulate method.




More information about the R-sig-mixed-models mailing list