sim_pred_hanova1 {bang}R Documentation

Simulate from a one-way hierarchical ANOVA posterior predictive distribution

Description

Simulates nrep draws from the posterior predictive distribution of the one-way hierarchical ANOVA model described in hanova1. This function is called within hanova1 when the argument nrep is supplied.

Usage

sim_pred_hanova1(theta_sim_vals, sim_vals, fac, nrep)

Arguments

theta_sim_vals

A numeric matrix with length(fac) columns. Each row of theta_sim_vals contains normal means simulated from their posterior distribution.

sim_vals

A numeric matrix with length(fac) columns. Each row of sim_vals contains normal standard deviations σ simulated from their posterior distribution.

fac

The argument fac to hanova1, that is, a vector of class factor indicating group membership.

nrep

A numeric scalar. The number of replications of the original dataset simulated from the posterior predictive distribution. If nrep is greater than nrow(theta_sim_vals) then nrep is set equal to nrow(theta_sim_vals).

Value

A numeric matrix with nrep columns. Each column contains a draw from the posterior predictive distribution of the number of successes.

Examples

RCP26_2 <- temp2[temp2$RCP == "rcp26", ]
temp_res <- hanova1(resp = RCP26_2[, 1], fac = RCP26_2[, 2])
sim_pred <- sim_pred_hanova1(temp_res$theta_sim_vals, temp_res$sim_vals,
                             RCP26_2[, 2], 50)

[Package bang version 1.0.1 Index]