During this workshop, you will …
We will …
...
with code)
Image by Josep Gesti
Image by News from Jerusalem
If you are using cloud server:
If you are running code locally:
Environment
column, combining Location
and Year
data
stepclass
statement in the modeling procEnvironment
column as in SASmutate()
: Transform existing columns or create new ones%>%
operator for better code readabilityacross()
: Apply same function to many columns, can use :
shorthandfava
proc sgplot
and proc sgpanel
with vbox
statementggplot()
with geom_boxplot()
, optionally facet_grid()
to make panelsggplot(fava, aes(x = Genotype, y = Yield)) +
geom_boxplot()
ggplot(fava, aes(x = Genotype, y = Yield, fill = Sowing, group = interaction(Genotype, Sowing))) +
geom_boxplot()
ggplot(fava, aes(x = Genotype, y = Yield, fill = Sowing, group = interaction(Genotype, Sowing))) +
geom_boxplot() +
facet_grid(Location ~ Year)
data
stepproc glimmix
for mixed model fittingYield ~ 1 + (1 | Block) + (1 | Sowing:Block)
Yield
) is on the left side of the formula~
separates the dependent from the independent variables+
1
)|
.
1
on the design side means only fit random intercepts and no random slopes(1 | Block)
: each block will get its own random intercept(1 | Sowing:Block)
: each main plot (unique combinations of Sowing and Block) will get its own random interceptdata
argument specifies the data frame that has the variables in the formulasubset
argument selects rows of the data frame to fit the model to
&
summary()
: residual summary, random effect variance/covariance, fixed effect estimates
Block
), main plot (Sowing:Block
), and subplot (Residual
because each data point is a subplot)ranef()
shows random effects, like random / solution
in SAS
icc()
shows intraclass correlation coefficient
Genotype + Sowing + Genotype:Sowing
:
indicates an interactionGenotype * Sowing
*
indicates all combinations of main effects and interaction termssummary(fit_1env_fixef)
ranef(fit_1env_fixef)
icc(fit_1env_fixef, by_group = TRUE)
anova()
anova(fit, ddf = 'Kenward-Roger')
Environment
, Block:Environment
, Sowing:Block:Environment
(main plot)plots = residualpanel
option within proc glimmix
gives you diagnosticscheck_model()
from the easystats package again(1 + Genotype + Sowing | Environment)
1
), genotype effect, and sowing effect for each environmentproc glimmix data = fava plots = residualpanel;
class Environment Block Sowing Genotype;
model Yield = Genotype|Sowing / solution;
random intercept Sowing / subject = Environment solution;
random intercept / subject = Sowing(Block Environment);
ods select parameterestimates tests3;
store fit_allenv_sowingrandomslope;
run;
proc glimmix
outputs AIC by defaultAIC()
to compare several models at once
lsmeans
lsmeans
does, and moreproc plm
but could also be done in proc glimmix
emmeans(fit, ~ fixedeffects)
fit
is fitted model object+
|
to compare means by treatment, within another treatmentplot(emm)
to make a basic plot with confidence intervalslines
and/or linestable
options in lsmeans
statementcld()
from the multcomp package (CLD = compact letter display)emmeans
object as first argumentWhat have you learned in this lesson?
Impressive!