# NOT RUN {
library(modelbased)
# Basic usage
model <- lm(Sepal.Width ~ Species, data = iris)
estimate_contrasts(model)
# Dealing with interactions
model <- lm(Sepal.Width ~ Species * Petal.Width, data = iris)
estimate_contrasts(model)
estimate_contrasts(model, fixed = "Petal.Width")
estimate_contrasts(model, modulate = "Petal.Width", length = 4)
estimate_contrasts(model, levels = "Petal.Width", length = 4)
# Standardized differences
estimated <- estimate_contrasts(lm(Sepal.Width ~ Species, data = iris))
effectsize::standardize(estimated)
# Other models (mixed, Bayesian, ...)
if (require("lme4")) {
data <- iris
data$Petal.Length_factor <- ifelse(data$Petal.Length < 4.2, "A", "B")
model <- lmer(Sepal.Width ~ Species + (1 | Petal.Length_factor), data = data)
estimate_contrasts(model)
}
data <- mtcars
data$cyl <- as.factor(data$cyl)
data$am <- as.factor(data$am)
# }
# NOT RUN {
if (require("rstanarm")) {
model <- stan_glm(mpg ~ cyl * am, data = data, refresh = 0)
estimate_contrasts(model)
estimate_contrasts(model, fixed = "am")
model <- stan_glm(mpg ~ cyl * wt, data = data, refresh = 0)
estimate_contrasts(model)
estimate_contrasts(model, fixed = "wt")
estimate_contrasts(model, modulate = "wt", length = 4)
estimate_contrasts(model, levels = "wt", length = 4)
model <- stan_glm(Sepal.Width ~ Species + Petal.Width + Petal.Length, data = iris, refresh = 0)
estimate_contrasts(model, fixed = "Petal.Width", modulate = "Petal.Length", test = "bf")
}
if (require("brms")) {
model <- brm(mpg ~ cyl * am, data = data, refresh = 0)
estimate_contrasts(model)
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab