Try length(yourvariablename) for all variables in the model. The first error message indicates that the vectors you are using are not of the same length (i.e. they do not contain the same number of observations).
The modeling question: Chickens are nested in nest (haha), but you don't have a nest indicator for each chicken in your data. Yr|ID won't pick up the dependence structure for chickens that are from the same nest. 1. Can chickens from different nests differ in mortality? - assume yes -> nest random effect 2. Are chickens nested in nests? - clearly yes - nested affect 3. Can circumstances in a year affect mortality? - assume yes (imagine bird flue or whatever you like) - This, to me, suggests a year fixed effect. 4. Are the same nests (or chicken mothers) measured in year 1 and year 2 - assume no Given the assumption above, I would try: y=b0+b1*HO+b2*(yr==1)+nest(i)+HO(ij)+e which would look like: model1 <- lmer(y~HO+factor(yr)+(1|nest)+(1|nest:HO),family=binomial,1) But ultimately you will have to answer the modeling question yourself and anyway test the model of whether you controll sufficiently for the dependence structure in your data. I suggest you to pick up Pinheiro and Bates's book and Faraway's "Extending the linear model with R". Cheers, Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Luciano La Sala Gesendet: Wednesday, December 03, 2008 11:22 AM An: r help Betreff: [R] GLMM using lme4 Dear R-experts, I am running R version 2.7.1 on Windows Vista. I have a small dataset which consists of chick ID, year (0, 1), hatching order [HO, defined as first, second and third-hatched chick], and the binary outcome of interest death (0, 1). So a subset of my dataset looks like this on a txt file: y ID Yr HO 1 1 1 First 0 2 1 First 0 3 1 Second 0 4 1 First 1 5 1 First 0 6 1 Third 0 7 1 First 0 8 1 Third 0 9 1 First 0 10 1 First 1 11 1 Third 0 12 1 First 0 13 1 First 0 14 1 First 0 15 1 First 0 17 1 First 1 19 1 First 1 20 1 First ............ n ni nj nk I need to run a GLMM using Year (Yr) and chick ID (ID) as random effects in order to account for lack of independence at the nest level (many chicks are siblings) and eliminate year effect incase a significant difference exists between years. Using lmer, I specified my model as follows: model1 <- lmer(y~HO+(Yr|ID),family=binomial,1) summary(model1) Output: Error en model.frame.default(data = 1, formula = y ~ HO + (Yr + ID), drop.unused.levels = TRUE) : las longitudes de las variables son diferentes (encontrada para 'HO') Q1: What does this error message mean and how can I solve the problema? Q2: Is my model correctly specified? I look forward to hearing from you guys, always so helpful. Lucho ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.