I have complete randomized block design with 3 treatment levels (control, moderate, heavy thinning in forest) and 3 replicates for each treatments. I collected rainfall under the canopy called as Throughfall(response variable). It was collected by monthly and study conducted 3 years. we considered treatment and month as fixed, year and replicates as random effects. So I have in my spreadsheet 324 cells total (12 month* 3 trt* 3 rep * 3 year). I just would like to have an anova table including SS, df, F value and P value for both fixed and random effects. here below that is only for fixed effect and I would like to report random effects and interactions too. I could not find the code which I can apply. Also how can I apply pairwise comparison? So can anyone help me about that? Thank you,
I run the code below:
library(MASS)
library(dplyr)
library(lme4)
library(Matrix)
test<-lmer( log ~ trt + as.factor(month) +trt*as.factor(month)+ (1| year )+ (1|rep) , data=dataf,REML="TRUE")
AIC(test)
summary(test)
anova(test)
######results####
Linear mixed model fit by REML ['lmerMod']
Formula: log ~ trt + as.factor(month) + trt * as.factor(month) + (1 | year) + (1 | rep2)
Data: dataf
REML criterion at convergence: 885.6
Scaled residuals:
Min 1Q Median 3Q Max
-1.9667 -0.7787 0.1229 0.6077 2.5410
Random effects:
Groups Name Variance Std.Dev.
year (Intercept) 0.009945 0.09973
rep2 (Intercept) 0.000000 0.00000
Residual 0.957992 0.97877
Number of obs: 324, groups: year, 3; rep2, 3
> anova(test)
Analysis of Variance Table
npar Sum Sq Mean Sq F value
trt 2 0.656 0.3282 0.3426
as.factor(month) 11 203.506 18.5006 19.3118
trt:as.factor(month) 22 0.270 0.0123 0.0128
I applied linear mixed model for my study, I would expect to have anova table.