library(nlme); library(emmeans); library(performance)
library(lme4)
13 Variance & Variance Components
13.1 Unequal Variance
13.1.1 Case 1: Unequal Variance Due to a Factor
<- here::here(read.csv("data", "MET_trial_variance.csv")) var_ex1
$block <- as.character(var_ex1$block)
var_ex1hist(var_ex1$yield)
boxplot(yield ~ site, data = var_ex1)
<- lme(yield ~ site:variety + variety,
m1_a random = ~ 1 |site/block,
na.action = na.exclude,
data = var_ex1)
<- update(m1_a, weights = varIdent(form = ~1|site)) m1_b
<- update(m1_a, weights = varIdent(form = ~1|site)) m1_b
is equivalent to
<- lme(yield ~ site:variety + variety,
m1_b random = ~ 1 |site/block,
weights = varIdent(form = ~1|site),
na.action = na.exclude,
data = var_ex1)
13.2 Coefficient of Variation
<- fixef(m2_b)[1]
m2_ave names(m2_b) <- NULL
= sigma(m2_b)/m2_ave*100
m2_cv m2_cv
13.2.1 Looking at Variance Components
<- read.csv(here::here("data", "potato_tuber_size.csv")) var_comps