sim_plot: Visualize Summaries of Simulation Results

Description Usage Arguments Examples

View source: R/simulation_tools.R

Description

Visualize Summaries of Simulation Results

Usage

1
sim_plot(x, ..., sample_sizes, stat = c("bias", "mc_var", "mse"))

Arguments

x

A list of several simulation summary objects, of class simulation_stats.

...

Extra arguments currently ignored.

sample_sizes

A numeric vector giving the sample sizes at which each of the simulations in the input x was performed. There should be one unique sample size corresponding to each element of x.

stat

A character indicating which of three simulation summary statistics for which to generate a plot. Options are currently limited to bias ("bias"), variance ("mc_var"), and mean-squared error ("mse").

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
n_sim <- 100
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)
    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)
p_sim_summary <- sim_plot(sim_summary, sample_sizes = n_obs, stat = "mse")
p_sim_summary

nima documentation built on March 13, 2020, 2:10 a.m.

Related to sim_plot in nima...