[R] Model building using lmer

Luciano La Sala luciano_la_sala at yahoo.com
Wed Dec 17 15:46:55 CET 2008


Dear R-experts,
Quite new to R on this end, but learning fast (I hope). 

I am running version 2.7.1 on Windows Vista. I have small dataset
which consists of: 

# NestID: nest indicator for each chicken. Siblings sharing the same nest have the same nest indicator. 

# Chick: chick indicator consisting of a unique ID for each single chick. 

# Year: 1, 2.

# ClutchSize: 1-, 2- , 3-eggs.  

# HO: hatching order within each clutch (1, 2, 3 [first, second and third-hatched chick]).

# SibComp: sibling competence: present/ absent (0, 1)

# Death2: death at two days post-hatch (0, 1)

# Death10: death at ten days post-hatch (0, 1)

So a subset of my dataset looks something like this:


NestID Chick Year ClutchSize HO Hatching SibComp Death2 Death10
1          1    1          1  1        1       1      1       1
2          2    1          1  1        1       1      0       0
3          3    1          1  1        0       0      0       0
4          4    1          1  1        1       0      1       0
4          5    1          2  2        0       1      0       1
5          6    1          2  1        1       0      0       0
5          7    1          2  2        0       0      0       0
6          8    2          3  1        1       1      0       0
6          9    2          3  2        1       0      1       0
6          10   2          3  3        0       1      0       0
7          11   2          3  1        0       0      0       1   
7          11   2          3  2        0       0      0       0 
7          11   2          3  3        1       1      1       1        
............

In order to account for lack of independence at the nest level (many chicks are siblings), I'd like to run a GLMM with random slopes and intercepts for nests.

Using lmer, my model for survival at 10 days, for example, would read as follows (or not!): 

> model <- lmer(Death10 ~ HO + ClutchSize + SibComp + Year + (1|NestID), family=binomial, 1)

> summary(model)

>From what I understand, the model above includes only random intercepts for NestID. So at this point my question is how do I make this model into one which includes both random intercepts and slopes for NestID? 

Look forward to receiving your input. Thank you all for your time! 

Luciano



More information about the R-help mailing list