Hello, I am trying to fit a model to data that are recorded in a doubly-repeated measures type design, and I'm having trouble with the syntax for lmer. The response is a count representing the number of animals harvested at each of six locations during a hunting season. Counts are recorded daily at each location for a fixed period (about 45 days). In addition, the daily counts at each location have been repeated themselves over several years (about 30). The dates of the counts are the same every year. Additional covariates are measured on a daily basis. Graphically, for all locations there is a clear trend in count by day, with some year-to-year variation. There are also clear but weaker trends in counts by year (for fixed day), with variation among locations. The general shape of the trend changes quite a bit depending on the day (e.g., early vs. late in the season). That said, the main interest is in understanding the influence of the covariates on harvest. I believe the following code fits a random intercept and slope model to daily counts within years, separately for each location. This model fits well, and allows testing of the covariate effects (X1 and X2). However it ignores the second layer of repetition and the trend in count by year, within locations. M1=lmer(log(Count+1)~X1+X2+Location+Day+(1+Day|Year), data=Harvest) I would like to know the correct syntax to also include terms for the repeated measurement by year, within locations. This model might be close, but I'm just not certain: M2=lmer(log(Count+1)~X1+X2+Day+(1+Day|Year/Location)+(1+Year|Location), data=Harvest) I'd appreciate any suggestions or advice. Thank you! Julie McIntyre
double repeated measures
3 messages · Julie McIntyre, Dexter Locke, John Maindonald
Hi, While this doesn't address the question about repeated measures, consider looking at O?Hara, R. B., Kotze, D. J., O ?Hara, R. B., & Kotze, D. J. (2010). Do not log-transform count data. Methods in Ecology and Evolution, 1(2), 118?122. https://doi.org/10.1111/j.2041-210X.2010.00021.x for the left-hand side of the model. - Dexter On Wed, Aug 9, 2017 at 10:52 PM, Julie McIntyre <jpmcintyre at alaska.edu> wrote:
Hello,
I am trying to fit a model to data that are recorded in a doubly-repeated
measures type design, and I'm having trouble with the syntax for lmer. The
response is a count representing the number of animals harvested at each of
six locations during a hunting season. Counts are recorded daily at each
location for a fixed period (about 45 days). In addition, the daily counts
at each location have been repeated themselves over several years (about
30). The dates of the counts are the same every year. Additional
covariates are measured on a daily basis.
Graphically, for all locations there is a clear trend in count by day, with
some year-to-year variation. There are also clear but weaker trends in
counts by year (for fixed day), with variation among locations. The
general shape of the trend changes quite a bit depending on the day (e.g.,
early vs. late in the season). That said, the main interest is in
understanding the influence of the covariates on harvest.
I believe the following code fits a random intercept and slope model to
daily counts within years, separately for each location. This model fits
well, and allows testing of the covariate effects (X1 and X2). However it
ignores the second layer of repetition and the trend in count by year,
within locations.
M1=lmer(log(Count+1)~X1+X2+Location+Day+(1+Day|Year), data=Harvest)
I would like to know the correct syntax to also include terms for the
repeated measurement by year, within locations. This model might be close,
but I'm just not certain:
M2=lmer(log(Count+1)~X1+X2+Day+(1+Day|Year/Location)+(1+Year|Location),
data=Harvest)
I'd appreciate any suggestions or advice. Thank you!
Julie McIntyre
[[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
All that the simulations in the O?Hara et al paper show is the E[log(y)] does not equal log(E[y]), where E[] is expectation. The O?Hara et al paper?s claim that "the transformations performed poorly? is just wrong, as it relates to what their simulations might demonstrate. See https://stats.stackexchange.com/questions/114848/negative-binomial-glm-vs-log-transforming-for-count-data-increased-type-i-erro/215080#215080 and the following paper that discusses the same sort of issue for RNA-Seq gene expression counts: Law, CW, Chen, Y, Shi, W, Smyth, GK (2014). Voom: precision weights unlock linear model analysis tools for RNA-seq read counts. Genome Biology 15, R29. http://genomebiology.com/2014/15/2/R29 I have an immediate interest in the equivalent issue for glmer models, used for insect dose-mortality data where the error is a version of over-dispersed binomial, with the amount of over-dispersion greatest around 50% mortality and reducing at high mortalities. Working with transformed mortality and an lmer() model does a much better job of modeling the within replicate variation than anything that one can readily do with a glmer() model that is set up to (strictly) handle only binomial error. One possibility for adapting glmer() may be to apply weights that are designed to ?fix up? the within replicate variance structure ? my impression is, however, that this adjusts both levels of the variance structure. The attempt to incorporate observation level random effects led (at least when I tried to fit a model that had random slopes and intercepts) to a message that the model was over-parameterized. The vignette cfAnalyses.html that can be found at https://github.com/jhmaindonald/qra-R-package/tree/master/vignettes looks at this issue, plus outliers issues! Practical data analysis can get very messy! John Maindonald email: john.maindonald at anu.edu.au<mailto:john.maindonald at anu.edu.au>
On 11/08/2017, at 01:06, Dexter Locke <dexter.locke at gmail.com<mailto:dexter.locke at gmail.com>> wrote:
Hi, While this doesn't address the question about repeated measures, consider looking at O?Hara, R. B., Kotze, D. J., O ?Hara, R. B., & Kotze, D. J. (2010). Do not log-transform count data. Methods in Ecology and Evolution, 1(2), 118?122. https://doi.org/10.1111/j.2041-210X.2010.00021.x for the left-hand side of the model. - Dexter On Wed, Aug 9, 2017 at 10:52 PM, Julie McIntyre <jpmcintyre at alaska.edu> wrote: Hello, I am trying to fit a model to data that are recorded in a doubly-repeated measures type design, and I'm having trouble with the syntax for lmer. The response is a count representing the number of animals harvested at each of six locations during a hunting season. Counts are recorded daily at each location for a fixed period (about 45 days). In addition, the daily counts at each location have been repeated themselves over several years (about 30). The dates of the counts are the same every year. Additional covariates are measured on a daily basis. Graphically, for all locations there is a clear trend in count by day, with some year-to-year variation. There are also clear but weaker trends in counts by year (for fixed day), with variation among locations. The general shape of the trend changes quite a bit depending on the day (e.g., early vs. late in the season). That said, the main interest is in understanding the influence of the covariates on harvest. I believe the following code fits a random intercept and slope model to daily counts within years, separately for each location. This model fits well, and allows testing of the covariate effects (X1 and X2). However it ignores the second layer of repetition and the trend in count by year, within locations. M1=lmer(log(Count+1)~X1+X2+Location+Day+(1+Day|Year), data=Harvest) I would like to know the correct syntax to also include terms for the repeated measurement by year, within locations. This model might be close, but I'm just not certain: M2=lmer(log(Count+1)~X1+X2+Day+(1+Day|Year/Location)+(1+Year|Location), data=Harvest) I'd appreciate any suggestions or advice. Thank you! Julie McIntyre _______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models _______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models