SCM

SCM Repository

[matrix] Diff of /pkg/R/lmer.R
ViewVC logotype

Diff of /pkg/R/lmer.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 963, Mon Oct 3 01:44:56 2005 UTC revision 973, Fri Oct 7 20:15:08 2005 UTC
# Line 954  Line 954 
954        })        })
955    
956  setMethod("simulate", signature(object = "lmer"),  setMethod("simulate", signature(object = "lmer"),
957            function(object, nsim = 1,            function(object, nsim = 1, seed = NULL, ...)
                    seed = runif(1, 0, .Machine$integer.max),  
                    ...)  
958        {        {
959            runif(1) ## to initialize the RNG if necessary            if(!exists(".Random.seed", envir = .GlobalEnv))
960                  runif(1)               # initialize the RNG if necessary
961              if(is.null(seed))
962            RNGstate <- .Random.seed            RNGstate <- .Random.seed
963              else {
964                  R.seed <- .Random.seed
965            set.seed(seed)            set.seed(seed)
966                  RNGstate <- structure(seed, kind = as.list(RNGkind()))
967                  on.exit(assign(".Random.seed", R.seed, envir = .GlobalEnv))
968              }
969    
970            family <- object@family            family <- object@family
971            if (family$family != "gaussian" ||            if (family$family != "gaussian" ||
# Line 984  Line 989 
989            ## add per-observation noise term            ## add per-observation noise term
990            lpred <- as.data.frame(lpred + rnorm(prod(dim(lpred)), sd = scale))            lpred <- as.data.frame(lpred + rnorm(prod(dim(lpred)), sd = scale))
991    
992            ## save the seed and restore the RNG state            ## save the seed
993            attr(lpred, "seed") <- seed            attr(lpred, "seed") <- RNGstate
           assign(".Random.seed", RNGstate, envir = .GlobalEnv)  
994            lpred            lpred
995        })        })
996    

Legend:
Removed from v.963  
changed lines
  Added in v.973

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge