Summarize Simulations Results

summarize_sim(simulation_results, truth, ci_level = 0.95)

Arguments

simulation_results

A data.frame, tibble or similar with exactly two columns named "param_est" and "param_var" giving the estimate of a parameter of interest and estimate of its variance (based on a valid variance estimator specific to that parameter).Each row of this data structure corresponds to the parameter estimate and variance for a single iteration of several simulations.

truth

A numeric value giving the true value of the parameter of interest in the simulation setting.

ci_level

A numeric value giving the level of the confidence intervals to be generated around the parameter estimates and statistics computed to summarize the simulation.

Examples

n_sim <- 1000 n_obs <- c(100, 10000) mu <- 2 sim_results <- lapply(n_obs, function(sample_size) { estimator_sim <- lapply(seq_len(n_sim), function(iter) { y_obs <- rnorm(sample_size, mu) est_param <- mean(y_obs) est_var <- var(y_obs) / sample_size estimate <- tibble::as_tibble(list( param_est = est_param, param_var = est_var )) return(estimate) }) estimates <- do.call(rbind, estimator_sim) return(estimates) }) sim_summary <- lapply(sim_results, summarize_sim, truth = mu) #