Simulate from a one-way hierarchical ANOVA posterior predictive distribution
Source:R/one_way_anova.R
sim_pred_hanova1.RdSimulates 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.
Arguments
- theta_sim_vals
A numeric matrix with
length(fac)columns. Each row oftheta_sim_valscontains normal means simulated from their posterior distribution.- sim_vals
A numeric matrix with
length(fac)columns. Each row ofsim_valscontains normal standard deviations \(\sigma\) simulated from their posterior distribution.- fac
The argument
factohanova1, 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
nrepis greater thannrow(theta_sim_vals)thennrepis set equal tonrow(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)