r i = {{i}}
r vars[i]
lc <- ck.crd(dfr, vars[i], trt) model <- aov(dfr[, vars[i]] ~ dfr[, trt]) model$terms[[2]] <- vars[i] at <- anova(model) rownames(at)[1] <- trt # ANOVA with subsampling show.anova.sub <- FALSE if (!is.null(eu)) if (dim(dfr)[1] < dim(dfr2)[1]) { model2 <- aov(dfr2[, vars[i]] ~ dfr2[, trt] + dfr2[, eu] %in% dfr2[, trt]) model2$terms[[2]] <- vars[i] at2 <- anova(model2) at2[1, 4] <- at2[1, 3] / at2[2, 3] at2[1, 5] <- pf(at2[1, 4], at2[1, 1], at2[2, 1], lower.tail = FALSE) rownames(at2) <- c(trt, "Exp. Error", "Sampling Error") show.anova.sub <- TRUE }
It is always good to have some visualization of your data. Below a histogram and a boxplot are shown.
par(mfrow = c(1, 2)) hist(dfr[, vars[i]], main = paste("Histogram of", vars[i]), xlab = vars[i]) boxplot(dfr[, vars[i]], ylab = vars[i])
r if (lc$ng < 10) {paste0("Since the number of ", trt.lab.s, " in your experiment is not so large, we can plot the data for each ", trt.lab, ":")}
if (lc$ng < 10) msdplot(dfr, vars[i], trt, conf = 1, xlab = trt.lab.sc, ylab = vars[i], pch = 4)
You have fitted a linear model for a CRD. The ANOVA table for your model is:
at
The coefficient of variation for this experiment is r format(agricolae::cv.model(model), digits = 4)
%.
The p-value for r trt.lab.s
is r format(at[1, 5], digits = 4)
r if(at[1, 5] < 0.05) {"which is significant at the 5% level."} else {"which is not significant at the 5% level."}
r if(show.anova.sub) {"At the subsample level, the ANOVA table is:"}
if (show.anova.sub)
at2
r if(show.anova.sub) {if (at2[2, 5] > 0.05) {"The p-value for the experimental error is non-significant which implies that plot to plot variation is low. Thus, fewer plots with more subsamples could be used."}}
r if(show.anova.sub) {if (at2[2, 5] < 0.05) {"The p-value for the experimental error is significant which implies that plot to plot variation is high. Thus, more plots could be used."}}
Don't forget the assumptions of the model. It is supposed that the errors are independent with a normal distribution and with the same variance for all the r trt.lab.s
. The following residuals plots can help you evaluate this:
par(mfrow = c(1, 2)) plot(model, which = 1) plot(model, which = 2)
Any trend in the residuals in the left plot would violate the assumption of independence while a trend in the variability of the residuals --for instance a funnel shape-- suggests heterogeneity of variances. Deviation from the theoretical normal line on the right plot is a sign of lack of normality.
r trt.lab.c
meansr if (at[1, 5] < 0.05 | mc) {paste("Below are the sorted means for each", trt.lab, "using the Fisher's Least Significant Difference method and the multiple comparisons method of Tukey, both at the 5% level. Letters indicate if there are significant differences")} else {paste("Because the effect of", trt.lab.s, "was not significant in the ANOVA, multiple comparison tests are not presented. The means of your", trt.lab.s, "are:")}
r if (at[1, 5] < 0.05 | mc) {paste0("### ", {{i+1}}, ".3.1. LSD test")}
if (at[1, 5] < 0.05 | mc) { means <- dfr[, vars[i]] agricolae::LSD.test(means, dfr[, trt], at[2, 1], at[2, 3])$groups }
r if (at[1, 5] < 0.05 | mc) {paste0("### ", {{i+1}}, ".3.2. Tukey test")}
if (at[1, 5] < 0.05 | mc) agricolae::HSD.test(means, dfr[, trt], at[2, 1], at[2, 3])$groups
if (at[1, 5] > 0.05 & !mc) tapply(dfr[, vars[i]], dfr[, trt], mean, na.rm = TRUE)
Below are the variance components for this model, under the assumption that r trt.lab.s
are random. Here the model is fitted using REML.
y <- dfr[, vars[i]] g <- dfr[, trt] ff <- as.formula(y ~ (1|g)) model <- lme4::lmer(ff) vc <- data.frame(lme4::VarCorr(model)) vc[1, 1] <- trt rownames(vc) <- vc[, 1] vc <- vc[, c(4, 5)] colnames(vc) <- c("Variance", "Std.Dev.") vc
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.