| distributions | R Documentation |
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.
Syntax Styles: In 'rtmb_code', you can specify distributions in two ways:
Sampling Syntax (Recommended): y ~ normal(mu, sigma)
Explicit Function Call: lp <- lp + normal_lpdf(y, mu, sigma)
Continuous Distributions (LPDF):
normal(mean, sd): Normal distribution.
lognormal(meanlog, sdlog): Lognormal distribution.
exp_mod_normal(mu, sigma, lambda): Exponentially modified normal distribution.
exponential(rate): Exponential distribution.
cauchy(location, scale): Cauchy distribution.
student_t(df, mu, sigma): Student's t-distribution.
gamma(shape, rate): Gamma distribution.
inverse_gamma(shape, scale): Inverse-gamma distribution.
beta(a, b): Beta distribution.
Discrete Distributions (LPMF):
bernoulli(prob) / bernoulli_logit(eta): Binary outcomes.
binomial(size, prob) / binomial_logit(size, eta): Binomial outcomes.
poisson(mean): Poisson count data.
neg_binomial_2(mu, size): Negative binomial (mean/dispersion parameterization).
ordered_logistic(eta, cutpoints): Ordered categorical outcomes.
sequential_logistic(eta, cutpoints): Sequential ordered categorical outcomes.
Multivariate and Matrix Distributions:
multi_normal(mean, Sigma): Standard multivariate normal distribution.
multi_student_t(df, mean, Sigma): Multivariate Student's t-distribution.
multi_cauchy(mean, Sigma): Multivariate Cauchy distribution (Student-t with df=1).
gaussian_process(x, mean, magnitude, smoothing, noise): Gaussian process prior with a squared exponential kernel.
lkj_corr(eta): LKJ prior for correlation matrices.
dirichlet(alpha): Dirichlet distribution for simplexes.
lower_tri_normal(mean, sd): Normal distribution for elements of a lower-triangular matrix.
centered_tri_multi_normal(sigma): Multivariate normal for centered triangular matrices (used in identification constraints).
sufficient_multi_normal_fa(S_mat, N, y_bar, mu, psi, Lambda): Factor analysis likelihood using sufficient statistics (highly efficient for large sample sizes).
Response-time Distributions:
diffusion(alpha, tau, beta, delta): Drift diffusion model likelihood for response times and binary choices. Use with obs(RT, Choice) ~ diffusion(...).
Vectorization:
Most univariate distributions are vectorized. If y and mu are vectors,
y ~ normal(mu, sigma) will calculate the sum of log-densities for all elements
efficiently.
Log-CDF and log-CCDF functions for supported univariate distributions use
the suffixes '_lcdf' and '_lccdf'; see distribution_cdf.
Other distributions:
distribution_cdf
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.