logLikWouPairs: Loglikelihood of WN in 2D when only the initial and final...

View source: R/RcppExports.R

logLikWouPairsR Documentation

Loglikelihood of WN in 2D when only the initial and final points are observed

Description

Computation of the loglikelihood for a WN diffusion (with diagonal diffusion matrix) from a sample of initial and final pairs of angles.

Usage

logLikWouPairs(x, t, alpha, mu, sigma, rho = 0, maxK = 2L, expTrc = 30)

Arguments

x

a matrix of dimension c(n, 4) of initial and final pairs of angles. Each row is an observation containing (\phi_0, \psi_0, \phi_t, \psi_t). They all must be in [\pi,\pi) so that the truncated wrapping by maxK windings is able to capture periodicity.

t

either a scalar or a vector of length n containing the times the initial and final dihedrals. If t is a scalar, a common time is assumed.

alpha

vector of length 3 parametrizing the A matrix as in alphaToA.

mu

a vector of length 2 giving the mean.

sigma

vector of length 2 containing the square root of the diagonal of \Sigma, the diffusion matrix.

rho

correlation coefficient of \Sigma.

maxK

maximum absolute value of the windings considered in the computation of the WN.

expTrc

truncation for exponential: exp(x) with x <= -expTrc is set to zero. Defaults to 30.

Details

A negative penalty is added if positive definiteness is violated. If the output value is Inf, -100 * N is returned instead.

Value

A scalar giving the final loglikelihood, defined as the sum of the loglikelihood of the initial angles according to the stationary density and the loglikelihood of the transitions from initial to final angles.

Examples

set.seed(345567)
x <- toPiInt(matrix(rnorm(200, mean = pi), ncol = 4, nrow = 50))
alpha <- c(2, 1, -0.5)
mu <- c(0, pi)
sigma <- sqrt(c(2, 1))

# The same
logLikWouPairs(x = x, t = 0.5, alpha = alpha, mu = mu, sigma = sigma)
sum(
  log(dStatWn2D(x = x[, 1:2], alpha = alpha, mu = mu, sigma = sigma)) +
  log(dTpdWou2D(x = x[, 3:4], x0 = x[, 1:2], t = 0.5, alpha = alpha, mu = mu,
                 sigma = sigma))
)

# Different times
logLikWouPairs(x = x, t = (1:50) / 50, alpha = alpha, mu = mu, sigma = sigma)

sdetorus documentation built on Aug. 21, 2023, 1:08 a.m.