[R-sig-eco] "random" lme syntax; related problem
Kingsford Jones
kingsfordjones at gmail.com
Tue Jul 22 21:06:48 CEST 2008
On Mon, Jul 21, 2008 at 2:36 AM, Maaike A Versteegh
<M.A.Versteegh at rug.nl> wrote:
> Dear Rafael and Kongston Jones (and others)
>
> I am also helping a colleague with quite similar data-set.
>
> He's interested in the effect of a lysozyme treatment on growth
> wing-lenght of chicks. He has has multiple chicks in nests but the
> treatment is on the nest level. So he has treated and untreated nests.
> He measured wing-length on day 2,4,8 and 15.
> He has a balanced design, with 40 treated and 40 untreated chicks, and
> 10 treated and 10 untreated nests.
>
> So he has chicks (who get an unique id: nstchk) nested in nests,
> measured on 4 days
> We tried the method Kingston Jones suggest (wing<-treat,
> random=~day|nest/nstchk).
I don't recall making that suggestion. If you plot the growth curves
for each chick by treatment or nest you'll see that's not a likely
model. Look at the plots and think about how you would test for
treatment effects using lm and it's associated assumptions (including
linearity), then try something similar with lme, adding covariance
structures for random effects and errors to produce more realistic
estimates of standard errors (and betas). You've got observations at
days within chicks within nests and you want to account for probable
correlations at each of those levels (noting you can't predict random
effects for nest/nstchk/day because there is only one observation at
that level, leaving no df for error). The errors at the day level
likely have temporal correlation with unequally spaced lags suggesting
what type of correlation structure to try. Also your variances are
non-homogeneous (in the sample data you sent) and the diagonal of the
error covariance matrix should be appropriately structured. As far as
the convergence issues the likely culprits are near singularities in
model matrices or flat likelihood surfaces. Following the suggestions
above may help.
If this advice is not readily clear I suggest consulting with a statistician.
Kingsford Jones
> If we do an lme with only the first two days
> (day 2 and day 4) it works fine. But if we try to run a lme on the data
> of all 4 days we get an error message. The error message is:
>
> Error in lme.formula(wing ~ treat, random = ~day | *nest/nstchk*, data =
> wdata) :
> nlminb problem, convergence error code = 1
> message = iteration limit reached without convergence (9)
>
> If he does not include nstchk (the unique id of the chicks) in the
> random part of the equation (so: random = ~day| nest), lme works fine
> with the data from all 4 days, but doesn't with just the data from day 2
> and day 4. It gives the same error message as above
>
> Both of the methods work with day 4 and day 8. Day 2 and day 15 also
> works with both models.
> As you can see we tried a lot, and we don't understands what makes it
> sometimes give error message and sometimes not.
>
> Can anybody help? could the problem be that we have too little variation
> in winglength on day 2? or too little growth between day 2 and day 4?
> Ideally my colleague would like to include all the days.
>
> Any help would be appreciated
>
> Maaike
>
> The complete R-code:
>
> wdata=read.csv("f:\\r practice\\wingtest320.2.4.8.15.csv")
> attach(wdata)
> names(wdata)
> library(nlme)
>
> model.with.nstchk<-lme(wing~treat,random=~day|nest/nstchk, data=wdata);
> summary(model.with.nstchk);
> model.no.nstchk<-lme(wing~treat,random=~day|nest, data=wdata);
> summary(model.no.nstchk)
>
>
> (part of) the data-set:
>
>
> treat nest chick nstchk day wing
> 1 LYS 209ward 1 209ward-1 2 9.0
> 2 LYS 209ward 1 209ward-1 4 13.5
> 3 LYS 209ward 1 209ward-1 8 34.0
> 4 LYS 209ward 1 209ward-1 15 64.0
> 5 LYS 209ward 2 209ward-2 2 9.0
> 6 LYS 209ward 2 209ward-2 4 13.0
> 7 LYS 209ward 2 209ward-2 8 32.0
> 8 LYS 209ward 2 209ward-2 15 63.0
> 9 LYS 209ward 3 209ward-3 2 8.5
> 10 LYS 209ward 3 209ward-3 4 13.5
> 11 LYS 209ward 3 209ward-3 8 32.5
> 12 LYS 209ward 3 209ward-3 15 63.0
> 13 LYS 209ward 4 209ward-4 2 8.5
> 14 LYS 209ward 4 209ward-4 4 12.5
> 15 LYS 209ward 4 209ward-4 8 34.0
> 16 LYS 209ward 4 209ward-4 15 61.0
> 17 LYS 209ward 5 209ward-5 2 9.0
> 18 LYS 209ward 5 209ward-5 4 13.0
> 19 LYS 209ward 5 209ward-5 8 34.0
> 20 LYS 209ward 5 209ward-5 15 62.5
> 21 LYS b13 1 b13-1 2 9.5
> 22 LYS b13 1 b13-1 4 14.0
> 23 LYS b13 1 b13-1 8 34.0
> 24 LYS b13 1 b13-1 15 65.0
> 25 LYS b13 2 b13-2 2 9.5
> 26 LYS b13 2 b13-2 4 14.5
> 27 LYS b13 2 b13-2 8 34.5
> 28 LYS b13 2 b13-2 15 64.0
> 29 LYS b40 1 b40-1 2 10.0
> 30 LYS b40 1 b40-1 4 13.5
> 31 LYS b40 1 b40-1 8 32.5
> 32 LYS b40 1 b40-1 15 65.5
> 33 LYS b40 2 b40-2 2 10.0
> 34 LYS b40 2 b40-2 4 14.5
> 35 LYS b40 2 b40-2 8 34.0
> 36 LYS b40 2 b40-2 15 66.0
> 37 LYS b40 3 b40-3 2 9.5
> 38 LYS b40 3 b40-3 4 14.0
> 39 LYS b40 3 b40-3 8 32.5
> 40 LYS b40 3 b40-3 15 64.5
> ....
> 161 PBS b1 1 b1-1 2 9.0
> 162 PBS b1 1 b1-1 4 12.5
> 163 PBS b1 1 b1-1 8 30.0
> 164 PBS b1 1 b1-1 15 57.5
> 165 PBS b1 2 b1-2 2 9.0
> 166 PBS b1 2 b1-2 4 14.5
> 167 PBS b1 2 b1-2 8 33.0
> 168 PBS b1 2 b1-2 15 59.0
> 169 PBS b1 4 b1-4 2 9.5
> 170 PBS b1 4 b1-4 4 14.0
> 171 PBS b1 4 b1-4 8 30.5
> 172 PBS b1 4 b1-4 15 58.0
> 173 PBS b1 5 b1-5 2 8.5
> 174 PBS b1 5 b1-5 4 12.5
> 175 PBS b1 5 b1-5 8 23.5
> 176 PBS b1 5 b1-5 15 55.0
> 177 PBS b18 1 b18-1 2 8.5
> 178 PBS b18 1 b18-1 4 13.0
> 179 PBS b18 1 b18-1 8 30.0
> 180 PBS b18 1 b18-1 15 63.5
> 181 PBS b18 2 b18-2 2 8.5
> 182 PBS b18 2 b18-2 4 12.0
> 183 PBS b18 2 b18-2 8 28.0
> 184 PBS b18 2 b18-2 15 65.0
> 185 PBS b18 3 b18-3 2 8.5
> 186 PBS b18 3 b18-3 4 13.5
> 187 PBS b18 3 b18-3 8 30.0
> 188 PBS b18 3 b18-3 15 64.0
> 189 PBS b19 1 b19-1 2 8.5
> 190 PBS b19 1 b19-1 4 13.0
> 191 PBS b19 1 b19-1 8 32.5
> 192 PBS b19 1 b19-1 15 64.0
> 193 PBS b19 2 b19-2 2 9.5
> 194 PBS b19 2 b19-2 4 14.0
> 195 PBS b19 2 b19-2 8 33.0
> 196 PBS b19 2 b19-2 15 68.0
> 197 PBS b19 3 b19-3 2 9.5
> 198 PBS b19 3 b19-3 4 13.0
> 199 PBS b19 3 b19-3 8 30.5
> 200 PBS b19 3 b19-3 15 63.5
> 201 PBS b19 4 b19-4 2 8.5
> 202 PBS b19 4 b19-4 4 13.5
> 203 PBS b19 4 b19-4 8 32.0
> 204 PBS b19 4 b19-4 15 66.0
> 205 PBS b19 5 b19-5 2 8.5
> 206 PBS b19 5 b19-5 4 11.0
> 207 PBS b19 5 b19-5 8 29.0
> 208 PBS b19 5 b19-5 15 61.5
> 209 PBS b42 1 b42-1 2 8.0
> 210 PBS b42 1 b42-1 4 13.0
> 211 PBS b42 1 b42-1 8 29.0
> 212 PBS b42 1 b42-1 15 63.0
> 213 PBS b42 2 b42-2 2 7.5
> 214 PBS b42 2 b42-2 4 11.5
> 215 PBS b42 2 b42-2 8 26.0
> 216 PBS b42 2 b42-2 15 58.0
> 217 PBS b42 3 b42-3 2 9.5
> 218 PBS b42 3 b42-3 4 14.5
> 219 PBS b42 3 b42-3 8 31.0
> 220 PBS b42 3 b42-3 15 65.0
> 221 PBS b42 4 b42-4 2 8.0
> 222 PBS b42 4 b42-4 4 12.0
> 223 PBS b42 4 b42-4 8 27.0
> 224 PBS b42 4 b42-4 15 62.5
> 225 PBS b42 5 b42-5 2 8.0
> 226 PBS b42 5 b42-5 4 11.0
> 227 PBS b42 5 b42-5 8 27.5
> 228 PBS b42 5 b42-5 15 65.0
>
>
>
>
>
>
> -- Maaike Versteegh Animal Ecology Group University of Groningen PO Box
> 14 9750 AA Haren The Netherlands phone +31 50 363 3408 fax +31 50 363
> 5205 e-mail m.a.versteegh at rug.nl
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
More information about the R-sig-ecology
mailing list