In my experimental design I have 4 treatments, 3 replicates per treatment and 3 blocks. In each plot I measured whether a plant is infested or not ("Infestate" variable). This measure has been performed to 30 to 40 plants placed at the centre of the plot. Sampling has been performed weekly (variable "Data_rilievo) on the same plants, even though the sample size might vary if some plants die. Treatment does not influence plant death. Thus, I removed from the dataset the observations resulted in plant death.
I obtained the following dataset:
'data.frame': 2937 obs. of 15 variables: $ ID_pianta : chr "_Pianta_1" "_Pianta_2" "_Pianta_3" "_Pianta_4" ... $ Data_rilievo : POSIXct, format: "2023-11-14" "2023-11-14" "2023-11-14" ... $ Blocco : num 2 2 2 2 2 2 2 2 2 2 ... $ Trattamento : chr "Controllo" "Controllo" "Controllo" "Controllo" ... $ Infestate : num 1 0 0 1 0 1 0 0 1 0 ...
I opted for a mixed-effect model with treatment as fixed effect, plant ID ("ID_pianta") as random effect to account for repeated measures, and block ("Blocco") as random effect.
And this is the result
> summary(model) Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod'] Family: binomial ( logit ) Formula: Infestate ~ Trattamento + (1 | ID_pianta) + (1 | Blocco) Data: data AIC BIC logLik deviance df.resid 3835.8 3871.7 -1911.9 3823.8 2931 Scaled residuals: Min 1Q Median 3Q Max -2.1969 -1.0611 0.6139 0.8091 1.5079 Random effects: Groups Name Variance Std.Dev. ID_pianta (Intercept) 0.16880 0.4108 Blocco (Intercept) 0.09686 0.3112 Number of obs: 2937, groups: ID_pianta, 40; Blocco, 3 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) 0.59808 0.20650 2.896 0.003776 ** TrattamentoLavanda -0.16521 0.11116 -1.486 0.137218 TrattamentoRosmarino -0.02389 0.11000 -0.217 0.828075 TrattamentoTimo -0.37733 0.11017 -3.425 0.000615 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) TrttmL TrttmR TrttmntLvnd -0.266 TrttmntRsmr -0.269 0.502 TrattamntTm -0.269 0.499 0.504
I wanted also to check the predictive abilities. I used this code
library(caret) data$Infestate