Euler approximation of the likelihood of a process solution of a stochastic differential equation. These functions are useful to calculate approximated maximum likelihood estimators when the transition density of the process is not known.
EULERloglik(X, theta, d, s, log =TRUE)
Arguments
X: a ts object containing a sample path of an sde.
theta: vector of parameters.
d,s: drift and diffusion coefficients; see details.
log: logical; if TRUE, the log-likelihood is returned.
Details
The function EULERloglik returns the Euler approximation of the log-likelihood. The functions s and d are the drift and diffusion coefficients with arguments (t,x,theta).
Returns
x: a number
Author(s)
Stefano Maria Iacus
Examples
set.seed(123)d <- expression(-1*x)s <- expression(2)sde.sim(drift=d, sigma=s)-> X
S <-function(t, x, theta) sqrt(theta[2])B <-function(t, x, theta)-theta[1]*x
true.loglik <-function(theta){ DELTA <- deltat(X) lik <-0for(i in2:length(X)) lik <- lik + dnorm(X[i], mean=X[i-1]*exp(-theta[1]*DELTA), sd = sqrt((1-exp(-2*theta[1]*DELTA))* theta[2]/(2*theta[1])),TRUE) lik
}xx <- seq(-3,3,length=100)sapply(xx,function(x) true.loglik(c(x,4)))-> py
sapply(xx,function(x) EULERloglik(X,c(x,4),B,S))-> pz
# true likelihoodplot(xx,py,type="l",xlab=expression(beta),ylab="log-likelihood")lines(xx,pz, lty=2)# Euler