| rtmb_corr | R Documentation |
'rtmb_corr' fits a correlation model to estimate means, standard deviations, and correlation structures. It supports simple correlation, multilevel correlation, and classical frequentist estimation.
rtmb_corr(
x = NULL,
data = NULL,
ID = NULL,
covariates = NULL,
method = c("pearson", "spearman", "reml"),
prior = prior_flat(),
y_range = NULL,
init = NULL,
fixed = NULL,
missing = c("listwise", "fiml", "pairwise"),
WAIC = FALSE
)
x |
A matrix, data frame, formula, or expression (e.g., |
data |
An optional data frame containing the variables. |
ID |
A character string or expression specifying the group ID variable for multilevel models. |
covariates |
Optional numeric matrix or data frame of covariates to be included in the joint MVN model. |
method |
Correlation method for |
prior |
Prior configuration object: 'prior_flat()', 'prior_normal()', or 'prior_weak()'. Default is 'prior_flat()'. For 'prior_normal()', correlation models use the aliases 'mean_sd' and 'sd_rate', which override the common arguments 'mu_sd' and 'sigma_rate'. An LKJ prior with 'lkj_eta = 1' is added automatically unless 'lkj_eta' is supplied explicitly. |
y_range |
Optional numeric vector or matrix defining the theoretical range (min, max) of response variables.
Required when using |
init |
Optional list of initial values. |
fixed |
Optional named list of fixed values for specific parameters. |
missing |
Missing value handling strategy: "listwise" (default), "pairwise", or "fiml" (Full Information Maximum Likelihood). |
WAIC |
Logical; if TRUE, add pointwise 'log_lik' to the generate block for WAIC. |
# Estimate the correlation between two variables in the debate dataset
data(debate, package = "BayesRTMB")
fit_corr <- rtmb_corr(cbind(sat, perf), data = debate)
mcmc_corr <- fit_corr$sample(sampling = 500, warmup = 500, chains = 2)
mcmc_corr$summary()
bf_corr <- mcmc_corr$bayes_factor(fixed = list(corr = 0))
print(bf_corr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.