Evaluates the loglikelihood function given SDE data and parameter values.
sde.loglik(model, x, dt, theta, ncores = 1)
model | An |
---|---|
x | A matrix or 3-d array of data with |
dt | A scalar or vector of length |
theta | A vector or matrix of parameters with |
ncores | If |
A vector of loglikelihood evaluations, of the same length as the third dimension of x
and/or first dimension of theta
. If input contains invalid data or parameters an error is thrown.
# load Heston's model hmod <- sde.examples("hest") # Simulate data nreps <- 10 nobs <- 100 theta <- c(alpha = 0.1, gamma = 1, beta = 0.8, sigma = 0.6, rho = -0.8) Theta <- apply(t(replicate(nreps, theta)), 2, jitter) x0 <- c(X = log(1000), Z = 0.1) X0 <- apply(t(replicate(nreps,x0)), 2, jitter) dT <- 1/252 hsim <- sde.sim(model = hmod, x0 = X0, theta = Theta, dt = dT, dt.sim = dT/10, nobs = nobs, nreps = nreps)#>#>#>#># single parameter, single data sde.loglik(model = hmod, x = hsim$data[,,1], dt = dT, theta = theta)#> [1] 687.1985# multiple parameters, single data sde.loglik(model = hmod, x = hsim$data[,,1], dt = dT, theta = Theta)#> [1] 687.3319 687.2974 687.0353 686.8871 687.1530 687.0873 686.9992 687.1027 #> [9] 687.0164 686.9412# multiple parameters, multiple data sde.loglik(model = hmod, x = hsim$data, dt = dT, theta = Theta)#> [1] 687.3319 726.3819 675.0533 624.7651 683.5307 701.0654 688.2960 673.7033 #> [9] 655.8494 680.2702