Hello Bonitta,

You may want to  try:

library(nlme)
fm1 <- lme(distance ~ age, data = Orthodont) # random is ~ age

library(nlmeU)
simY <- simulateY(fm1, nsim =5)

Internallly, simulateY  employs  getVarCov.lme method  function from nlme
package. For this reason it will not work for models with multiple levels
of nesting.

More details about simulateY function in Section 20.4 of the  Galecki,
Burzykowski book "Linear Mixed-Effects Models Using R: A step-by-step
approach" (2013).

Best wishes

Andrzej

On Wed, Dec 4, 2013 at 12:50 PM, Ben Bolker <bbolker@gmail.com> wrote:

> bbonit@... <bbonit@...> writes:
>
> >
> >  Dear list i have a question :
> >
> > how can i extract simulated value from simulate function in nlme ? (if it
> is possible)
> > thank You so much
> > sorry for noise
> > Bonitta Gianluca
>
>   I think you may be out of luck -- that is, I don't think that
> simulate.lme stores the simulated values.  If I run the example
> in ?simulate.lme and examine the resulting object, I get:
>
> str(orthSim)
> List of 2
>  $ null:List of 2
>   ..$ ML  : num [1:1000, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
>   .. ..- attr(*, "dimnames")=List of 2
>   .. .. ..$ : chr [1:1000] "1" "2" "3" "4" ...
>   .. .. ..$ : chr [1:2] "info" "logLik"
>   ..$ REML: num [1:1000, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
>   .. ..- attr(*, "dimnames")=List of 2
>   .. .. ..$ : chr [1:1000] "1" "2" "3" "4" ...
>   .. .. ..$ : chr [1:2] "info" "logLik"
>  $ alt :List of 2
>   ..$ ML  : num [1:1000, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
>   .. ..- attr(*, "dimnames")=List of 2
>   .. .. ..$ : chr [1:1000] "1" "2" "3" "4" ...
>   .. .. ..$ : chr [1:2] "info" "logLik"
>   ..$ REML: num [1:1000, 1:2] 0 0 0 0 0 0 0 0 0 0 ...
>   .. ..- attr(*, "dimnames")=List of 2
>   .. .. ..$ : chr [1:1000] "1" "2" "3" "4" ...
>   .. .. ..$ : chr [1:2] "info" "logLik"
>  - attr(*, "call")= language simulate.lme(object =
>   list(fixed = distance ~ age, data = Orthodont,
>    random = ~1 |      Subject), nsim = 1000,
>    m2 = list(random = ~age | Subject))
>  - attr(*, "seed")= int 61390140
>  - attr(*, "df")= num 2
>  - attr(*, "useGen")= logi FALSE
>  - attr(*, "class")= chr "simulate.lme"
>
> In words -- the ML and REML criteria are stored for the reduced
> and full models for each simulation, but not the values themselves.
> You *might* be able to hack the function: the critical lines are
>
> base2 <- base + rnorm(N, sd = sig)
>         for (j in 1:Q) {
>             base2 <- base2 + ((array(rnorm(ngrp[j] * qvec[j]),
>                 c(ngrp[j], qvec[j]), list(1:ngrp[j], NULL)) %*%
>                 DeltaInv[[j]])[ind[[j]], , drop = FALSE] * condL1$Xy[,
>                 csq1[j]:csq2[j], drop = FALSE]) %*% rep(1, qvec[j])
>         }
>
> _______________________________________________
> R-sig-mixed-models@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]

