Skip to contents

Given a matrix of simulated coefficient estimates and the true coefficient vector, compute per‐variable summary statistics: the empirical mean and standard deviation of the estimates, alongside the true value.

Usage

summarize_coef(sims_coef, true_theta, decimal = 2)

Arguments

sims_coef

Numeric matrix of dimension \(p \times n_{\text{sim}}\), where each row corresponds to one predictor and each column to a simulation replicate.

true_theta

Numeric vector of length \(p\), containing the true coefficient values for each predictor.

decimal

Nonnegative integer.

Value

A data.frame with columns:

true

The true coefficient values, from true_theta.

mean

Row‐wise mean of sims_coef, the average estimated coefficient.

ssd

Row‐wise standard deviation of sims_coef, the empirical sampling variability.

Examples

# Suppose we ran 100 simulations for 3 predictors
set.seed(42)
true_theta <- c(1.5, 0, -2)
sims_coef  <- matrix(rnorm(3 * 100, mean = rep(true_theta, each = 100), sd = 0.3),
                     nrow = 3, byrow = TRUE)
summarize_coef(sims_coef, true_theta)
#>   true  mean  ssd
#> 1  1.5  1.51 0.31
#> 2  0.0 -0.03 0.27
#> 3 -2.0 -2.00 0.31