#-------------------------------------------------------------
## Example 2.2.1.7 p-42
#-------------------------------------------------------------
# PROC GLM DATA=ex121;
# CLASS dose;
# MODEL PCVdif=dose;
# ESTIMATE 'l vs mh' dose -0.5 1 -0.5;
# CONTRAST 'l vs mh' dose -0.5 1 -0.5;
# RUN;
str(ex121)
fm2.1 <-
aov(
formula = PCVdiff ~ dose
, data = ex121
, projections = FALSE
, qr = TRUE
, contrasts = NULL
# , ...
)
if (requireNamespace("report", quietly = TRUE)) {
fm2.1 |>
report::report()
}
summary(fm2.1)
anova(fm2.1)
LvsMHConc <-
matrix(
data = c(-0.5, 1, -0.5)
, nrow = length(levels(ex121$dose))
, byrow = FALSE
, dimnames = list(
c(levels(ex121$dose))
, c("Low vs Mediam and Hight")
)
)
contrasts(ex121$dose) <- LvsMHConc
fm2.2 <-
aov(
formula = PCVdiff ~ dose
, data = ex121
, projections = FALSE
, qr = TRUE
, contrasts = NULL
# , ...
)
if (requireNamespace("report", quietly = TRUE)) {
fm2.2 |>
report::report()
}
summary(fm2.2, split = list(dose = list("Low vs Mediam and Hight" = 1)))
fm2.3 <-
lm(
formula = PCVdiff ~ dose
, data = ex121
# , subset
# , weights
# , na.action
, method = "qr"
, model = TRUE
, x = FALSE
, y = FALSE
, qr = TRUE
, singular.ok = TRUE
, contrasts = NULL
# , offset
# , ...
)
if (requireNamespace("report", quietly = TRUE)) {
fm2.3 |>
report::report()
}
if (requireNamespace("emmeans", quietly = TRUE)) {
emm2.3 <- emmeans::emmeans(fm2.3, ~ dose)
print(emm2.3)
print(emmeans::contrast(
emm2.3,
method = list(low_vs_medium_high = c(-0.5, 1, -0.5))
))
}
summary(fm2.3)
anova(fm2.3)
# multcomp::glht(
# model = fm2.3
# , linfct = LvsMHConc
# , alternative = "two.sided" # c("two.sided", "less", "greater")
# , rhs = 0
# )
Run the code above in your browser using DataLab