Hi everyone. I'd really appreciate help with the following analysis.
Apologies for such a basic question; I looked for previous queries on similar data, but none seem to quite fit what I am after. I have a field experiment aimed at understanding how the presence of "bodyguard" ants regulates the abundance of butterfly eggs and larvae (and the damage the latter cause) on a focal plant species. For this, I set up fourteen pairs of plants in a nature reserve and then assigned each plant in each pair to one of two treatments, either "with ants" or "without ants", by applying a physical barrier at the base of the plant. In the following nine weeks I measured four response variables once a week on a subsample of ten randomly chosen leaves of each plant. I thus have nine repeated measures on each plant. My response variables are: ants: number of ants (this was measured just to check the physical barrier had worked OK) eggs: number of butterfly eggs larvae: number of butterfly larvae dam: percent leaf damage (percentage eaten by larvae) My explanatory variables are: treat: treatment (two levels: "con" and "sin" mean with and without ants, respectively) pair: plant pair date For each response variable I would like to build a model that accounts for the lack of independence of data within each pair, and that considers the fact that data come from repeated measures (so, for instance, leaf damage tends to accumulate). My specific question is if including the random term "pair" in the model accomplishes both things. I guess it probably doesn't, so I'd appreciate any suggestions. The results indicate plants without ants have a higher number of eggs (which is what we expected, yeaeee), but without proper control of the autocorrelations I mentioned I am not convinced. I provide a workable example below. #read data from Google drive #each line represents the variables measured on a single leaf of a single plant on a single date. id <- "0Bzd8I1jr8z_iU0h6R0hxaElseDA" # google file ID gaston <- read.table(sprintf("<a href="https://docs.google.com/uc?id=%s&export=">https://docs.google.com/uc?id=%s&export= download", id), head=T) #GLMM require(lme4); require(effects) M1 <- glmer(eggs ~ treat + (1|pair), data=gaston, family=poisson) #check if there are any significant effects of treatment summary(M1) allEffects(M1) Thanks in advance for your help. Best, Mariano ___ Dr. Mariano Devoto Profesor Adjunto - Cátedra de Botánica General, Facultad de Agronomía de la U.B.A. Investigador Adjunto del CONICET Av. San Martin 4453 C1417DSE C.A. de Buenos Aires Argentina http://www.agro.uba.ar/users/mdevoto/ [[alternative HTML version deleted]] _______________________________________________ R-sig-ecology mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-ecology |
I think you're pretty close. You want a factor that identifies the individual plant to get the repeated measures part correct, and I would add a fixed effect of days from the start to capture the trend over time (if there is one). So:
library(tidyverse) library(lubridate) gaston <- mutate(gaston, plant = paste0(pair,treat), date = dmy(date), day = as.numeric((date - min(date))/86400)) ggplot(gaston, aes(x=day, y=eggs)) + geom_jitter(aes(shape=treat)) + facet_wrap(~pair) M1 <- glmer(eggs ~ treat*day + (1|pair/plant), data=gaston, family=poisson) And you should check for overdispersion. You might also check with r-sig-mixed-models. -- Drew Tyre School of Natural Resources University of Nebraska-Lincoln 416 Hardin Hall, East Campus 3310 Holdrege Street Lincoln, NE 68583-0974 phone: +1 402 472 4054 fax: +1 402 472 2946 email: [hidden email] http://snr.unl.edu/tyre http://atyre2.github.io ________________________________ From: R-sig-ecology <[hidden email]> on behalf of Mariano Devoto <[hidden email]> Sent: Saturday, March 4, 2017 6:32:17 AM To: [hidden email] Subject: [R-sig-eco] glmm on paired data with repeated measures Hi everyone. I'd really appreciate help with the following analysis. Apologies for such a basic question; I looked for previous queries on similar data, but none seem to quite fit what I am after. I have a field experiment aimed at understanding how the presence of "bodyguard" ants regulates the abundance of butterfly eggs and larvae (and the damage the latter cause) on a focal plant species. For this, I set up fourteen pairs of plants in a nature reserve and then assigned each plant in each pair to one of two treatments, either "with ants" or "without ants", by applying a physical barrier at the base of the plant. In the following nine weeks I measured four response variables once a week on a subsample of ten randomly chosen leaves of each plant. I thus have nine repeated measures on each plant. My response variables are: ants: number of ants (this was measured just to check the physical barrier had worked OK) eggs: number of butterfly eggs larvae: number of butterfly larvae dam: percent leaf damage (percentage eaten by larvae) My explanatory variables are: treat: treatment (two levels: "con" and "sin" mean with and without ants, respectively) pair: plant pair date For each response variable I would like to build a model that accounts for the lack of independence of data within each pair, and that considers the fact that data come from repeated measures (so, for instance, leaf damage tends to accumulate). My specific question is if including the random term "pair" in the model accomplishes both things. I guess it probably doesn't, so I'd appreciate any suggestions. The results indicate plants without ants have a higher number of eggs (which is what we expected, yeaeee), but without proper control of the autocorrelations I mentioned I am not convinced. I provide a workable example below. #read data from Google drive #each line represents the variables measured on a single leaf of a single plant on a single date. id <- "0Bzd8I1jr8z_iU0h6R0hxaElseDA" # google file ID gaston <- read.table(sprintf("<a href="https://docs.google.com/uc?id=%s&export=">https://docs.google.com/uc?id=%s&export= download", id), head=T) #GLMM require(lme4); require(effects) M1 <- glmer(eggs ~ treat + (1|pair), data=gaston, family=poisson) #check if there are any significant effects of treatment summary(M1) allEffects(M1) Thanks in advance for your help. Best, Mariano ___ Dr. Mariano Devoto Profesor Adjunto - C�tedra de Bot�nica General, Facultad de Agronom�a de la U.B.A. Investigador Adjunto del CONICET Av. San Martin 4453 C1417DSE C.A. de Buenos Aires Argentina http://www.agro.uba.ar/users/mdevoto/ [[alternative HTML version deleted]] _______________________________________________ R-sig-ecology mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-ecology [[alternative HTML version deleted]] _______________________________________________ R-sig-ecology mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-ecology |
Free forum by Nabble | Edit this page |