knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(expdean)

lm_list() function

mt_trial <- mtcars %>%
  rownames_to_column("vehicle_name") %>%
  as_tibble() %>%
  mutate_at(c("vehicle_name", "vs", "am"), as.factor)

lm_model_list1 <- lm_list(mt_trial, c("mpg", "drat", "qsec"), c("am", "vs", "am:vs", "hp"))

model_mean_differences() function

Linear mixed model can be fitted using lme package. Marginal and conditional means of continuous response variables can be extracted from this model class or lmer objects using estimated marginal means available in emmeans package.

# pairwise comparison between treatment levels
pairs(emmeans::emmeans(lm_model_list1, "am"))
# p-value comparison
emmeans::pwpp(emmeans::emmeans(lm_model_list1, "am"))

Model contrasts and contrast coefficients can be assessed.

# contrasts
emmeans::contrast(emmeans::emmeans(lm_model_list1, "am"))
coef(emmeans_contrast) # contrast coefficients can be assessed

Pairwise comparison of estimated marginal means:

multcomp::cld(emmeans::emmeans(lm_model_list1, "am")) # compact display


DeependraD/expdean documentation built on Nov. 25, 2019, 12:33 a.m.