Hi again. Perhaps a simple question this time.... I am analysing data with a dependent variable of insect counts, a fixed effect of site and two random effects, day, which is the same set of 10 days for each site, and then transect, which is nested within site (5 each). I am trying to fit the cross classified model using GLMM in lme4. I have, for potential use, created a second coding of transect with levels 1-5 for site 1 and 6-10 for site2. Likewise, if a groupedData object is necessary, there are als ts1 and ts2 dummy variables, as was necessary in the old lme..... > str(dat3) `data.frame': 100 obs. of 7 variables: $ site : Factor w/ 2 levels "Here","There": 1 1 1 1 1 1 1 1 1 1 ... $ day : Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ... $ trans : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ... $ count : int 77 109 81 124 115 84 90 85 130 106 ... $ trans2: Factor w/ 10 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ... $ ts1 : Factor w/ 10 levels "Here 1","Here 2",..: 1 2 3 4 5 1 2 3 4 5 ... $ ts2 : Factor w/ 10 levels "Here 1","Here 2",..: 1 2 3 4 5 1 2 3 4 5 ... Might someone explain to me how I might reflect the fact that transects are different between sites, while days are not? #this does not work, though I thought it might be the best way to specify the model..... > GLMM(count~site,data=dat3,random=list(day=~1,trans=~1|site,family=poisso n) Error in GLMM(count ~ site, data = dat3, random = list(day = ~1, trans = ~1 | : subscript out of bounds In addition: Warning message: "|" not meaningful for factors in: Ops.factor(1, site) #This does... but also note the differences in the summary and VarCorr variance components... >summary(GLMM(count~site,data=dat3,random=list(day=~1,trans2=~1),family= poisson)) Generalized Linear Mixed Model Family: poisson family with log link Fixed: count ~ site Data: dat3 AIC BIC logLik 103.1494 116.1753 -46.5747 Random effects: Groups Name Variance Std.Dev. trans2 (Intercept) 0.073011 0.27020 day (Intercept) 0.034373 0.18540 # of obs: 100, groups: trans2, 10; day, 10 Estimated scale (compare to 1) 0.6232135 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) 4.66280 0.13502 34.534 <2e-16 *** siteThere -0.25572 0.17216 -1.485 0.1375 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 Correlation of Fixed Effects: (Intr) siteThere -0.636 >VarCorr(GLMM(count~site,data=dat3,random=list(day=~1,trans2=~1),family= poisson)) Groups Name Variance Std.Dev. trans2 (Intercept) 0.028936 0.17010 day (Intercept) 0.013623 0.11672 Residual 0.396322 0.62954 Many thanks andrew
> I am analysing data with a dependent variable of insect > counts, a fixed effect of site and two random effects, day, > which is the same set of 10 days for each site, and then > transect, which is nested within site (5 each).And what exactly are you interested in? Just the differences between the two sites? Then you would have sampled on several days just to better estimate what is going on at those sites? Or are you also interested in a time course?> I am trying to fit the cross classified model using GLMM in lme4.I have yet to get around to working with lme4 (by the way is there some documentation that describes the changes and advantages of lme4 in comparison to nlme?), but assuming that the syntax is the same as in lme () or glmmPQL (): Why don't you use: GLMM (count ~ site, data= dat3, random= ~ 1 | site/trans, family= poisson) This compares your counts between sites considering that transects are nested in sites and that there are several measurements on each transect (the days). They are the repeated measurements on the lowest level (within trans), so you do not need to specify them explicitly. Acutally, you might not even need the site/ in your random term as this variable ist constant for each transect and thus the degrees of freedom are adjusted for the fixed effect of site (but then each of the transect need its own code). Well on further thought, you might necessarily need to leave this part of the random term away if you want to conduct any statistical test, because otherwise you only have an N= 1 for each site ... thus, I guess you need to assume that your transects are independent measures of your two sites (which means that you can conduct some statistical analysis, but you results hold only for these two specific sites and can not necessarily be generalised to other sites). Thus the model would be: GLMM (count ~ site, data= dat3, random= ~ 1 | trans2, family= poisson) or if you are interested in a time course you might try (and this explicitely models that these are the same days): GLMM (count ~ site*day, data= dat3, random= ~ 1 | trans2, family= poisson) I would argue, that you are either not interested in the days, then these are just your repeated measurements and it does not matter that they were exactly on the same days for the different transects (and then they are just implicitly nested in trans2) OR you are interested in them and then I would include them as a fixed effect, which is crossed with transect, i.e. all transects were sampled on all days. By the way, it is not clear to me from your description how trans2, ts and ts2 differ logically.> there are als ts1 and ts2 dummy variables, as was necessary > in the old lme.....what are these necessary for? (But I have to admit that I usually feed a standard data.frame to lme and glmmPQL)> GLMM(count~site,data=dat3,random=list(day=~1,trans=~1|site, > family=poisson)I do not know whether you can write such a thing at all. If this has not changed a lot from nlme to lme4 you would need to write: random= list (~1 | day, ~ 1 | site/trans) but that you would implicitly define that site is nested in day, i.e. it would be the same as writing random= ~ 1 | day/site/trans which is not what you want.> #This does... but also note the differences in the summary > and VarCorr variance components...Here, you loose me completely. It is not clear to me what you compare and where you perceive a problem. Cheers, Lorenz - Lorenz Gygax, Dr. sc. nat. Centre for proper housing of ruminants and pigs Swiss Federal Veterinary Office agroscope FAT T?nikon, CH-8356 Ettenhausen / Switzerland