sumsim: Summarize Simulation Results

Description Usage Arguments Value Examples

View source: R/sumsim.R

Description

Creates table summarizing results of statistical simulations, providing common metrics of performance like mean bias, standard deviation, mean standard error, mean squared error, and confidence interval coverage.

Usage

1
2
sumsim(estimates, ses = NULL, truth = NULL, statistics = c("mean_bias",
  "sd", "mean_se", "mse", "coverage"), alpha = 0.05, digits = 3)

Arguments

estimates

Numeric matrix where each column gives the point estimates for a particular method across multiple trials.

ses

Numeric matrix where each column gives the standard errors for a particular method across multiple trials.

truth

Numeric value specifying the true value of the parameter being estimated.

statistics

Numeric vector specifying which performance metrics should be calculated. Possible values are "mean", "median", "mean_bias", "median_bias", "sd", "iqr", "mean_se" (for mean standard error), "mse" (for mean squared error), and "coverage" (for confidence interval coverage).

alpha

Numeric value specifying alpha for confidence interval. Set to 0.05 for the usual 95% CI, 0.1 for a 90% CI, and so forth.

digits

Numeric value or vector specifying the number of decimal places to include.

Value

Numeric matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# For X ~ N(mu, sigma^2), the MLE for sigma^2 is the sample variance with n 
# in the denominator, but the unbiased version with (n - 1) is typically used 
# for its unbiasedness. Compare these estimators in 1,000 trials with n = 25. 
MLE <- c()
Unbiased <- c()
for (ii in 1: 1000) {
   x <- rnorm(n = 25)
   MLE[ii] <- sum((x - mean(x))^2) / 25
   Unbiased[ii] <- sum((x - mean(x))^2) / 24
 }
sumsim(estimates = cbind(MLE, Unbiased), truth = 1)

dvmisc documentation built on May 2, 2019, 5:51 p.m.

Related to sumsim in dvmisc...