I was asked to build a mixed effect model using 'lmer' and 'lmerTest'. The data is shown below:
The full Question is :
"Use the lme4
and lmerTest
R packages to run a linear mixed-effects model examining how herbivores (Herbivory
), pollinators (Pollination
), plant defences (HCN
) and all interactions influence the length of banner petals (Avg.Bnr.Wdth
) produced by plants while accounting for variation due to spatial block and plant genotype. Allow the intercept for Genotype
to vary across the levels of the herbivory treatment (Hint: are Genotype
and Herbivory
crossed or nested?)"
My attempt to build a model:
model_2a <- lmer(data = plant_data, Avg.Bnr.Wdth ~ Herbivory * Pollination +
Herbivory * HCN +
Pollination * HCN +
(1|Block) +
(1|Genotype))
summary(model_2a)
However, the output is odd:
Scaled residuals:
Min 1Q Median 3Q Max
-4.7400 -0.5967 0.0692 0.6326 3.2019
Random effects:
Groups Name Variance Std.Dev.
Genotype (Intercept) 0.068569 0.2619
Block (Intercept) 0.003272 0.0572
Residual 0.046580 0.2158
Number of obs: 595, groups: Genotype, 49; Block, 6
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 3.270378 0.062366 58.163245 52.438 <2e-16 ***
HerbivoryReduced 0.005644 0.031429 540.971084 0.180 0.8575
PollinationSupp -0.051416 0.031547 538.253166 -1.630 0.1037
HCNYes -0.110019 0.081633 58.795573 -1.348 0.1829
HerbivoryReduced:PollinationSupp 0.013405 0.036148 539.473352 0.371 0.7109
HerbivoryReduced:HCNYes 0.062927 0.036135 539.454401 1.741 0.0822 .
PollinationSupp:HCNYes 0.071009 0.035959 539.235883 1.975 0.0488 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) HrbvrR PllntS HCNYes HrR:PS HR:HCN
HerbvryRdcd -0.262
PollintnSpp -0.246 0.328
HCNYes -0.640 0.132 0.117
HrbvryRd:PS 0.150 -0.589 -0.609 0.001
HrbvrR:HCNY 0.156 -0.581 0.012 -0.241 0.022
PllntS:HCNY 0.133 0.038 -0.536 -0.214 -0.021 -0.036
First. I have no idea how to "vary the Genotype intercept across the Herbivory treatment."
Second. Why it's "HerbivoryReduced","PollinationSupp" in the output, I tried to as.factor
Pollination, Herbivory and HCN, but it still shows the same thing