predictExposureEff {fkbma}R Documentation

Predict Exposure Effect

Description

This function predicts the exposure effect for new data based the Reversible Jump MCMC (rjMCMC) results.

Usage

predictExposureEff(results, newdata = NULL)

Arguments

results

An object of class rjMCMC containing the output from the rjMCMC procedure, which includes:

fixed_param

Matrix of posterior samples for exposure intercept and main effect.

binary_param

Matrix of posterior samples for binary variable parameters.

sigma_sq

Matrix of posterior samples for the residual variance (sigma squared).

vars_prop_summ

Posterior inclusion probabilities for candidate variables.

splines_fitted

List of matrices containing fitted values for spline terms across iterations.

data_fit

Original dataset used in the rjMCMC procedure.

candsplineinter

Names of continuous candidate predictive spline variables.

candsplinevars

Names of continuous candidate spline variables.

candbinaryvars

Names of binary candidate variables.

candinter

Names of interaction terms, which can include spline variables.

mcmc_specs

MCMC sampler specifications, including the number of iterations, burn-in, thinning, and chains.

newdata

A data frame for which predicted values are to be computed If NA, the original fitted data is used.

Details

The function:

Spline interactions are handled by interpolating the spline coefficients for the values in newdata.

Value

A matrix of predictive posterior samples for the exposure effect, where each row corresponds to a posterior sample and each column corresponds to an observation in newdata.

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")
newdata = data.frame(Z_1 = 1, Z_2 = 1, Z_3 = 1, Z_4 = 1, Z_5 = 1,
                   trt = 1, X_1 = seq(0,1,by=0.01))
predictExposureEff(results)
predictExposureEff(results,newdata)


[Package fkbma version 0.2.0 Index]