rhats {fkbma} | R Documentation |
Calculate and Print Rhat Diagnostics for rjMCMC Results
Description
This function calculates the Rhat diagnostic for convergence based on the posterior samples of individual exposure effects, intercept, and main exposure effect from an rjMCMC model. It prints the median, minimum, and maximum Rhat values for the exposure effects, as well as the Rhat for the intercept and exposure effect.
Usage
rhats(results)
Arguments
results |
An object of class rjMCMC containing the output from the
|
Details
This function calculates R-hat statistics to assess MCMC convergence for both exposure effects and model parameters. Diagnostic plots are generated to visually inspect the chains across iterations.
Value
A list containing:
- Rhat_trt_eff_posterior
Vector of R-hat values for each individual's exposure effect.
- Rhat_inter
R-hat value for the intercept parameter.
- Rhat_factor_var
R-hat value for the main effect of exposure.
Examples
# Example dataset
data("simulated_data")
candsplinevars <- c("X_1")
candbinaryvars <- paste0("Z_", 1:5)
candinter <- c(candsplinevars, candbinaryvars)
results <- rjMCMC(simulated_data, candsplinevars, candbinaryvars, candinter,
outcome = "Y", factor_var = "trt")
rhats(results)