Summarise simulation results from extracted model estimates
Source:R/model_evaluation.R
evaluate_model_results.Rd
Computes summary statistics (e.g., power, custom summaries) across a set of
extracted model results, typically from extract_model_results()
, to facilitate
simulation evaluation and reporting.
Usage
evaluate_model_results(
results,
alpha = 0.05,
...,
.summarise_standard_broom = FALSE,
broom_cols = c("estimate", "std.error", "statistic", "df", "p.value")
)
Arguments
- results
A data frame of extracted model results, typically including columns like
term
,estimate
,std.error
,statistic
, andp.value
.- alpha
Significance level used to compute power. Defaults to
0.05
.- ...
Additional summary expressions to compute within
dplyr::summarise()
. These may include calls to helper functions likeeval_bias()
,eval_quantile()
, or direct summaries such asmean(estimate, na.rm = TRUE)
.- .summarise_standard_broom
Logical; if
TRUE
, computes mean and standard deviation for standardbroom
columns present in the data (columns inbroom_cols
). Defaults toFALSE
.- broom_cols
Character vector of standard
broom
columns to summarise if.summarise_standard_broom = TRUE
. Defaults toc("estimate", "std.error", "statistic", "df", "p.value")
.
Value
A summarised data frame containing:
n_models
: the number of models summarised.power
: the proportion of p-values less thanalpha
(NA if all p-values are NA).Additional columns corresponding to custom summaries provided in
...
.Mean and SD summaries of
broom
columns if.summarise_standard_broom = TRUE
.
Examples
library(dplyr)
#> Error in library(dplyr): there is no package called ‘dplyr’
library(purrr)
library(broom.mixed)
#> Error in library(broom.mixed): there is no package called ‘broom.mixed’
# Simulate and fit models
sim_models <- tibble(
id = 1:50,
model = map(1:50, ~ lm(mpg ~ wt, data = mtcars))
) |>
extract_model_results()
#> Error in loadNamespace(x): there is no package called ‘tidyr’
# Evaluate power and mean estimate for the slope
sim_models |>
filter(term == "wt") |>
evaluate_model_results(
alpha = 0.05,
mean_estimate = mean(estimate, na.rm = TRUE),
sd_estimate = sd(estimate, na.rm = TRUE)
)
#> Error in loadNamespace(x): there is no package called ‘dplyr’
# Evaluate with .summarise_standard_broom = TRUE
sim_models |>
filter(term == "wt") |>
evaluate_model_results(
.summarise_standard_broom = TRUE
)
#> Error in loadNamespace(x): there is no package called ‘dplyr’
# Evaluate with eval_bias to compute bias relative to the true value
# Suppose the true slope of wt is -5 (hypothetical)
sim_models |>
filter(term == "wt") |>
evaluate_model_results(
bias = eval_bias(
estimate,
term = c("wt" = -5)
)
)
#> Error in loadNamespace(x): there is no package called ‘dplyr’