Helpful Stan Functions
Frank Copula Functions

Functions

real frank_copula_lpdf (vector u, vector v, real theta)
 

Detailed Description

The Frank copula bivariate cumulative density function is defined as

\[ C(u,v) = -\frac{1}{\omega}\ln \big[1 + \frac{(\exp(-\omega u) - 1)(\exp(-\omega v)-1)}{\exp(-\omega) -1} \big] \]

for \(\omega \in (-\infty, \infty) \,/\ \{0\}\).

The Frank copula bivariate probability density function is defined as

\[ c(u, v) = \frac{ \partial^2 C(u, v) }{ \partial u \partial v} = \frac{\omega (1 - \exp(-\omega))(\exp(-\omega(u + v)))}{[ (1 - \exp(-\omega)) - (1 - \exp(-\omega u))(1 - \exp(-\omega v))]^2} \]

real frank_copula_lpdf(vector u, vector v, real theta) {
int N = num_elements(u);
real log_lik;
if (theta < 0)
log_lik = N * log(theta * (1 - exp(-theta))) - theta * sum(append_col(u, v))
- sum(log((-expm1(-theta) - (expm1(-theta * u)) .* (expm1(-theta * v))) ^ 2));
else
log_lik = N * (log(theta) + log1m_exp(-theta)) - theta * sum(append_col(u, v))
- 2 * sum(log(-expm1(-theta) - (expm1(-theta * u)) .* (expm1(-theta * v))));
return log_lik;
}
real frank_copula_lpdf(vector u, vector v, real theta)
Definition: frank_copula.stanfunctions:30

Function Documentation

◆ frank_copula_lpdf()

real frank_copula_lpdf ( vector  u,
vector  v,
real  theta 
)

Frank Bivariate Copula Log Density

Sean Pinkney
The copula is defined \(\omega \in (-\infty, \infty) \,/\ \{0\}\)

Parameters
uVector with elements in \((0,1]\), not checked but function will return NaN
vVector with elements in \((0,1]\), not checked but function will return NaN

omega Real number on (-Inf, Inf) / {0}, values of \omega greater than 37 will result in overflow

Returns
log density