Skip to content

random effects specification

5 messages · Ken Beath, Andrew Robinson, Julie Marsh +1 more

#
Hi again,

I've made further explorations into lmer, toying with the example I
showed earlier:


---<---------------cut here---------------start-------------->---
set.seed(1000)
rCom <- rnorm(2, mean=5, sd=0.5)
rTr <- rep(rCom / 1.1, 2)
nbase <- rnorm(60, 10, 0.1)

## 20 individuals; 10 in community "A" and 10 in "B", each receiving 3
## different treatments once.
dta <- within(expand.grid(community=LETTERS[1:2], treatment=letters[1:3],
                          id=1:10), {
                              id[community == "B"] <- id[community == "B"] + 10
                              id <- as.factor(id)
                              n <- rCom[as.numeric(community)] +
                                  rTr[as.numeric(treatment)] + nbase
                          })
dta <- dta[order(dta$id, dta$community, dta$treatment), ]

## Simulate an interaction
dta$n[dta$community == "A"] <- rev(dta$n[dta$community == "A"])
## Have a look
xyplot(n ~ treatment | community, data=dta, groups=id,
       type="b", pch=19, cex=0.3)

## We test for community (A, B) and treatment (a, b, c) fixed effects,
## their interactions, and use random effects for subject (1:20).  Am I
## writing this correctly?
##
## y_{ijk} = B_j + B_k + B_{jk} + b_i + e_{ijk}    i=1,...,20; j=A,B; k=a,b,c
n.lmer1 <- lmer(n ~ community * treatment + (1 | id), dta)
---<---------------cut here---------------end---------------->---


I'm a bit confused whether I'm describing the model being fit correctly
(not the lmer call, but the model description in the comment above), and
how it could be described in matrix form.  I think this type of
exercises would help me grasp the syntax conventions better.

Another issue is that the lmer call results in a warning:

---<---------------cut here---------------start-------------->---
Warning message:
In .local(x, ..., value) :
  Estimated variance for factor ?id? is effectively zero
---<---------------cut here---------------end---------------->---


which I presume is due to the fact that the data are unreplicated,
i.e. individuals get each treatment only once.  Are there any gotchas in
the interpretation of the results after this warning?

Thanks once again!
#
On 01/05/2008, at 11:28 PM, Sebastian P. Luque wrote:

            
No. Due to not having a random component for id in the simulated data.

Try

rid <- rep(rnorm(20),each=3)
dta$n <- dta$n+rid

Then refit the model.
Probably not, but with real data I would remove the random effect from  
the model as it is 0.

Ken
#
Hi Sebastian,
On Thu, May 01, 2008 at 08:28:11AM -0500, Sebastian P. Luque wrote:
I think so.
I'm not sure what you're looking for here.  Matrix form as I
understand it tends to be pretty generic.  But, have a go and we can
critique it :)
No, I think that it's because you didn't assign any subject to subject
variation to the observations. n comprises a contribution from
community, from treatment, and from the base error, but not from id.
Try adding id-based variation.
I would ordinarily interpret that message as meaning that the model is
overparameterized.  That seems to be true, here.

Andrew
3 days later
#
Dear Sebastian,

Sounds as if you have received great advice already.  Just a short  
note - I believe you are missing the fixed-effect intercept in your  
model which I have denoted as simply "B" in your notation below.  This  
is often denoted as Beta0 or B0 in textbooks (sorry no subscripts or  
greek letters printing in this email!).

y_{ijk} = B + B_j + B_k + B_{jk} + b_i + e_{ijk}    i=1,...,20; j=A,B; k=a,b,c

kindest regards,  julie.




Quoting "Sebastian P. Luque" <spluque at gmail.com>:
#
Dear lmers,

Indeed this has been a very helpful thread.  Thanks to all for your
feedback/time!

All the best,
Sebastian



On Mon, 05 May 2008 10:12:59 +0800,
Julie Marsh <marshj02 at student.uwa.edu.au> wrote:

            

        
Cheers,