% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distributions.R
\name{distributions}
\alias{distributions}
\title{Probability Distributions for RTMB Models}
\description{
This page summarizes the probability distributions available within the `rtmb_code` block.
These functions are designed to be used with the Stan-like sampling syntax (`~`),
which internally adds the log-density to the model's total log-posterior.
}
\details{
\strong{Syntax Styles:}
In `rtmb_code`, you can specify distributions in two ways:
\itemize{
  \item \strong{Sampling Syntax (Recommended):} \code{y ~ normal(mu, sigma)}
  \item \strong{Explicit Function Call:} \code{lp <- lp + normal_lpdf(y, mu, sigma)}
}

\strong{Continuous Distributions (LPDF):}
\itemize{
  \item \code{normal(mean, sd)}: Normal distribution.
  \item \code{lognormal(meanlog, sdlog)}: Lognormal distribution.
  \item \code{exponential(rate)}: Exponential distribution.
  \item \code{cauchy(location, scale)}: Cauchy distribution.
  \item \code{student_t(df, mu, sigma)}: Student's t-distribution.
  \item \code{gamma(shape, rate)}: Gamma distribution.
  \item \code{inverse_gamma(shape, scale)}: Inverse-gamma distribution.
  \item \code{beta(a, b)}: Beta distribution.
}

\strong{Discrete Distributions (LPMF):}
\itemize{
  \item \code{bernoulli(prob)} / \code{bernoulli_logit(eta)}: Binary outcomes.
  \item \code{binomial(size, prob)} / \code{binomial_logit(size, eta)}: Binomial outcomes.
  \item \code{poisson(mean)}: Poisson count data.
  \item \code{neg_binomial_2(mu, size)}: Negative binomial (mean/dispersion parameterization).
  \item \code{ordered_logistic(eta, cutpoints)}: Ordered categorical outcomes.
  \item \code{sequential_logistic(eta, cutpoints)}: Sequential ordered categorical outcomes.
}

\strong{Multivariate and Matrix Distributions:}
\itemize{
  \item \code{multi_normal(mean, Sigma)}: Standard multivariate normal distribution.
  \item \code{multi_student_t(df, mean, Sigma)}: Multivariate Student's t-distribution.
  \item \code{multi_cauchy(mean, Sigma)}: Multivariate Cauchy distribution (Student-t with df=1).
  \item \code{lkj_corr(eta)}: LKJ prior for correlation matrices.
  \item \code{dirichlet(alpha)}: Dirichlet distribution for simplexes.
  \item \code{lower_tri_normal(mean, sd)}: Normal distribution for elements of a lower-triangular matrix.
  \item \code{centered_tri_multi_normal(sigma)}: Multivariate normal for centered triangular matrices (used in identification constraints).
  \item \code{sufficient_multi_normal_fa(S_mat, N, y_bar, mu, psi, Lambda)}: Factor analysis likelihood using sufficient statistics (highly efficient for large sample sizes).
}

\strong{Vectorization:}
Most univariate distributions are vectorized. If \code{y} and \code{mu} are vectors,
\code{y ~ normal(mu, sigma)} will calculate the sum of log-densities for all elements
efficiently.
}
\concept{distributions}
