# NOT RUN {
# show all columns in output tibble
options(tibble.width = Inf)
# for reproducibility
set.seed(123)
#------------------------- models with *t*-statistic ------------------
# model with t-statistic
ggstatsplot:::ggcoefstats_label_maker(x = broomExtra::tidy(stats::lm(
data = mtcars, formula = wt ~ cyl * mpg
)), statistic = "t")
# (in case `x` is not a dataframe, no need to specify `statistic` argument;
# this will be figured out by the function itself)
#------------------------- models with *t*-statistic ------------------
# dataframe
clotting <- data.frame(
u = c(5, 10, 15, 20, 30, 40, 60, 80, 100),
lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18),
lot2 = c(69, 35, 26, 21, 18, 16, 13, 12, 12)
)
# model
mod <-
stats::glm(
formula = lot1 ~ log(u),
data = clotting,
family = Gamma
)
# model with t-statistic
ggstatsplot:::ggcoefstats_label_maker(
x = mod,
tidy_df = broomExtra::tidy(
x = mod,
conf.int = TRUE,
conf.level = 0.95
)
)
#------------------------- models with *z*-statistic --------------------
# preparing dataframe
counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12)
outcome <- gl(3, 1, 9)
treatment <- gl(3, 3)
d.AD <- data.frame(treatment, outcome, counts)
# model
mod <- stats::glm(
formula = counts ~ outcome + treatment,
family = poisson(),
data = d.AD
)
# creating tidy dataframe with label column
ggstatsplot:::ggcoefstats_label_maker(x = mod, tidy_df = broomExtra::tidy(mod))
#------------------------- models with *f*-statistic --------------------
# creating a model object
op <- options(contrasts = c("contr.helmert", "contr.poly"))
npk.aov <- stats::aov(formula = yield ~ block + N * P * K, data = npk)
# extracting a tidy dataframe with effect size estimate and their CIs
tidy_df <-
groupedstats::lm_effsize_ci(
object = npk.aov,
effsize = "omega",
partial = FALSE,
nboot = 50
) %>%
dplyr::rename(.data = ., estimate = omegasq, statistic = F.value)
# including a new column with a label
ggstatsplot:::ggcoefstats_label_maker(
x = npk.aov,
tidy_df = tidy_df,
effsize = "omega",
partial = FALSE
)
# }
Run the code above in your browser using DataLab