Skip to content
Back to formatted view

Raw Message

Message-ID: <40e66e0b0804070929q250f3805qaf128754c6b5f89d@mail.gmail.com>
Date: 2008-04-07T16:29:50Z
From: Douglas Bates
Subject: Simulating linear mixed models - the Venables approach

In case you missed it on the R-help list, I urge readers of this list
to consider the understated elegance of the code Bill Venables posted
for simulating data from a simple random effects model.

> set.seed(7658943)
>
> fph <- 0.4
> Sigh <- sqrt(0.0002)
> Sigi <- sqrt(0.04)
>
> reH <- rnorm(90, fph, Sigh)  ## hospid effects
> dta <- within(expand.grid(hospid = 1:90, empid = 1:80),
           fpi1 <- reH[hospid] + rnorm(7200, fph, Sigi))

One is reminded of John Keats

 'Beauty is truth, truth beauty,?that is all	
 Ye know on earth, and all ye need to know.'