plot_ppc | R Documentation |
plot_ppc
plots posterior predictions in a variety of ways.
plot_ppc(
train_indiv = list(),
train_trials = list(),
test_perf = list(),
id = NULL,
group_title = "",
legend_pos = "right",
pal = NULL,
font = "",
font_size = 14,
...
)
train_indiv |
List, maximum length 3. The first element should be an
individual-level |
train_trials |
List, maximum length 3. The first element should be a
trial-level |
test_perf |
List, maximum length 3. The first element should be a
individual-level |
id |
subjID to select if only plots for a single participant are desired. Will also accept a single numeric value i, which will select the ith participant in the output. |
group_title |
Sets consistent titles for all plots. |
legend_pos |
Enables the legend positions to be set manually. |
pal , font , font_size |
Same as |
... |
Other rarely used arguments which set the number of trials/blocks or the name of the predicted variable. |
Either a single or named list
of ggplot
objects.
## Not run:
data(example_data)
dir.create("outputs/cmdstan/predictions")
fit <- fit_learning_model(
example_data$nd,
model = "2a",
vb = FALSE,
exp_part = "training",
iter_sampling = 2000,
outputs = c("model_env", "raw_df", "stan_datalist")
)
pred_paths <- generate_posterior_quantities(
fit_mcmc = fit$fit,
data_list = fit$stan_datalist,
return_type = "paths"
)
obs_df_preds <- get_preds_by_chain(
out_files = pred_paths,
out_dir = "outputs/cmdstan/predictions",
obs_df = fit$raw_df,
n_draws_chain = 2000
)
ind <- readRDS("outputs/cmdstan/predictions/indiv_obs_sum_ppcs_df.RDS")
tri <- readRDS("outputs/cmdstan/predictions/trial_block_avg_hdi_ppcs_df.RDS")
# Cumulative choice probabilities, block-lagged
plot_ppc(
train_indiv = list(ind, 20),
group_title = "Cumulative choice probabilities"
)
# Difference between observed and predicted choice, over the whole task
# i.e., 120 trials per type
plot_ppc(
train_indiv = list(ind, list(), 120),
group_title = "Difference between observed and predicted choices"
)
# Individual-level predictions and observed choice probabilities, across task
## N.B. partial match can be used to plot the types in names(tri$types)
## e.g., using "block_6" to plot "AB_block_6", "CD_block_6", and "EF_block_6"
plot_ppc(
train_trials = list(tri, "all_trials"),
group_title = "Individual-level choices against predictions"
)
# Test plots can be plotted similarly with test_perf - the second and third
# arguments follow the same logic as plot_import(plt.test)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.