Description Usage Arguments Details Value Examples
Simulate datasets from the model previously fit. This function has the additional capability of simulating new data.
1 | do_simulation(model_array, new_values = NA, nsim = 1, seed = NULL)
|
model_array |
a tibble retreived from the |
new_values |
a data frame or tibble containing the values of each predictor to simulate at. Defaults to the given dataset. |
nsim |
the number of datasets to simulate |
seed |
an integer specifying how to initialize the random number generator |
This simulation function first uses the model to determine the average value at a given set of predictors. Then it generates a random number from the specified type of distribution using the parameters retreived from the prediction.
If a grouping variable was indicated then the simulation is carried out separately for each group.
This function is only supported for the frequentist methods.
A tibble with each row representing one simulated value. Additional model information is returned including the type of model, the equation corresponding to the model, and teh value of the predictors at which a given value was simulated from.
1 2 3 4 5 6 7 | trial_data <- tibble(w = runif(20, 0, 2), x = sample(c(1,2), 20, TRUE), y = rbinom(20, 15, .75))
new_data <- tibble(w = runif(5, 1, 2.5))
pois_model <- make_pois(w) %>% fit_model(frequentist, trial_data, y)
pois_model %>% do_simulation()
pois_model %>% do_simulation(new_data)
pois_model %>% do_simulation(new_data, 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.