% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrapper_corr.R
\name{rtmb_corr}
\alias{rtmb_corr}
\title{Fit a Correlation Model using RTMB}
\usage{
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
)
}
\arguments{
\item{x}{A matrix, data frame, formula, or expression (e.g., \code{cbind(V1, V2)}) of response variables.}

\item{data}{An optional data frame containing the variables.}

\item{ID}{A character string or expression specifying the group ID variable for multilevel models.}

\item{covariates}{Optional numeric matrix or data frame of covariates to be included in the joint MVN model.}

\item{method}{Correlation method for \code{classic()}: \code{"pearson"}, \code{"spearman"}, or \code{"reml"}.}

\item{prior}{Prior configuration object: `prior_flat()`, `prior_normal()`, or `prior_weak()`. Default is `prior_flat()`.}

\item{y_range}{Optional numeric vector or matrix defining the theoretical range (min, max) of response variables.
Required when using \code{prior_weak()}. Can be a vector of length 2 (applies to all variables) or a matrix/list of length P.}

\item{init}{Optional list of initial values.}

\item{fixed}{Optional named list of fixed values for specific parameters.}

\item{missing}{Missing value handling strategy: "listwise" (default), "pairwise", or "fiml" (Full Information Maximum Likelihood).}

\item{WAIC}{Logical; if TRUE, add pointwise `log_lik` to the generate block for WAIC.}
}
\description{
`rtmb_corr` fits a correlation model to estimate means, standard deviations, and correlation structures.
It supports simple correlation, multilevel correlation, and classical frequentist estimation.
}
\examples{

  # Estimate the correlation between two variables in the debate dataset
  data(debate, package = "BayesRTMB")

  fit_corr <- rtmb_corr(cbind(sat, perf), data = debate)

  \donttest{
  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)
  }
}
