Skip to contents

These functions compute the cross-correlations of the MCMC samples in an JointAI object via coda::crosscorr() and plot them using either the corrplot package or coda::crosscorr.plot().

Usage

cross_corr(object, outcome = NULL, start = NULL, end = NULL,
  thin = NULL)

cross_corr_plot(object, outcome = NULL, start = NULL, end = NULL,
  thin = NULL, type = "corrplot")

Arguments

object

an object of class JointAI

outcome

optional; vector identifying the sub-models whose parameters are included, either by their indices (in the order of the list of model formulas) or their names (LHS of the respective model formula as character string). If NULL (default), all monitored parameters are included. With parameters from several sub-models, the coefficients are named "outcome: variable", otherwise by the variable only.

start

the first iteration of interest (see window.mcmc)

end

the last iteration of interest (see window.mcmc)

thin

thinning interval (integer; see window.mcmc). For example, thin = 1 (default) will keep the MCMC samples from all iterations; thin = 5 would only keep every 5th iteration.

type

character; type of plot to be produced. Either "corrplot" (default) or "coda".

Value

a matrix (or a plot)

Examples

fit <- lm_imp(y ~ C1 + C2 + B2, data = wideDF, n.iter = 200)
cross_corr(fit)
#>              (Intercept)           C1           C2        B21      sigma_y
#> (Intercept)  1.000000000 -0.999337698 -0.009232185  0.1058412 -0.004013081
#> C1          -0.999337698  1.000000000  0.006052573 -0.1407318  0.004398230
#> C2          -0.009232185  0.006052573  1.000000000  0.1199271 -0.006365958
#> B21          0.105841151 -0.140731823  0.119927130  1.0000000 -0.010219705
#> sigma_y     -0.004013081  0.004398230 -0.006365958 -0.0102197  1.000000000
cross_corr_plot(fit, type = "coda")