I conducted an experiment where earthworms were subjected to two treatments, with and without herbicide in the soil. Biomass measurements were taken every 12 days for 398 days and the biomass growth curves as a function of time were plotted. There was clearly a non-linear growth pattern such that an additive mixed effects model was proposed to model the behavior of biomass as a function of time and treatments. When plotting the residuals a clear cone-shaped pattern was observed, therefore a series of additive models were proposed sequentially to deal with violations of the assumption of homogeneity. Below we can see the models with the following names: M.1; M.2; M.3; M.4

lmc <- lmeControl (niterEM = 5000, msMaxIter = 1000)
f1 <- formula (Biomass ~ Treat + s (Time, by = Treat))

M.1 <-gamm (f1, random = list (fcajita = ~ 1), method = "REML", control = lmc, data = Acorticis)

This first model uses the experimental box factor (i.e. fcajita) as the random element of the model. This random effects model assumes homogeneity between the experimental boxes and within them over time

M.2 <-gamm (f1, random = list (fcajita = ~ 1), method = "REML", control = lmc, data = Acorticis, weights = varIdent (form = ~ 1 | fcajita))

This second model assumes heterogeneity between boxes, but homogeneity within each box over time

M.3 <- gamm (f1, random = list (fcajita = ~ 1), method = "REML", control = lmc, data = Acorticis, weights = varExp (form = ~ Time10))

The third model assumes homogeneity between boxes but heterogeneity within each box over time

Finally, we decided to model the heterogeneity using the 'varComb' function in order to combine the variances where the model allows heterogeneity between the experimental boxes and heterogeneity within the experimental boxes over time:

M.4 <- gamm (f1, random = list (fcajita = ~ 1), data = Acorticis,
method = "REML", control = lmc, weights = varComb (varIdent (form = ~ 1 | fcajita), varPower (form = ~ Time10)))

The first three models executed perfectly and the following values ​​of the AIC indicator were obtained:

> AIC (M.1 $ lme, M.2 $ lme, M.3 $ lme)

        df AIC

M.1 $ lme 8 379.6464
M.2 $ lme 15 309.5736
M.3 $ lme 9 310.4828

Unfortunately, the execution of the M.4 model failed and the following error message was obtained:

Error in environment (attr (ret $ lme $ modelStruct $ varStruct, "formula")) <-. GlobalEnv:
attempt to set an attribute on NULL

My question is: Could someone help me fix this problem to run the M.4 model?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.