I am interested in how a response varies between time periods, and regions. My question revolves around nesting of random effects, specifically putting site (unique within each region) as a random effect.
Simulated data set for mixed effects modelling
factor1 <- c(rep("a", 100), rep("b", 100))#time period
factor2 <- rep(rep(1:5, 20), 2) #5 unique regions
factor3 <- c(1:100, 1:100)#100 unique sites
response <- c(rnorm(100, 10, 3), rnorm(100, 15, 3))
df <- data.frame(time.period = factor1, region = as.factor(factor2), site = as.factor(factor3), response = response)
df %>% str() #structure of the data
#quick visual
ggplot(df, aes(time.period, response)) + geom_boxplot() + facet_grid(~region)
lm1 <- lm(response ~ time.period*region, data=df)#fixed effects model
anova(lm1)
summary(lm1)
I received comments from a reviewer which stated that the "among site variation should be controlled for as random effects". Specifically, they suggested nesting the random effect of site within the fixed effect of region. They also suggested that including a site effect would potentially remove a region effect.
I'm having trouble conceptually with this, and have the following questions
1) Would you even need to nest site within region? Each site has a unique identifier, so wouldn't nesting be unnecessary?
2) How would including a random site effect "remove a region effect"? Doesn't that imply making region a random effect?
*Note that I actually have multiple observations within each time period (2-4).
Below is the code I've written for implementing the suggested approach:
library(lme4)
lme1 <- lmer(response ~ time.period*region*(1|site), data=df)
anova(lme1)
summary(lme1)