#===============================================================================
# Simulate a time inhomogeneous diffusion.
#-------------------------------------------------------------------------------
data(SDEsim1)
attach(SDEsim1)
par(mfrow=c(1,1))
expr1=expression(dX[t]==2*(5+3*sin(0.5*pi*t)-X[t])*dt+0.5*sqrt(X[t])*dW[t])
plot(Xt~time,type='l',col='blue',xlab='Time (t)',ylab=expression(X[t]),main=expr1)
#------------------------------------------------------------------------------
# Define coefficients of the process.
#------------------------------------------------------------------------------
GQD.remove()
G0 <- function(t){theta[1]*(theta[2]+theta[3]*sin(0.25*pi*t))}
G1 <- function(t){-theta[1]}
Q0 <- function(t){theta[4]*theta[4]}
theta.start <- c(1,1,1,1) # Starting values for the chain
mesh.points <- 10 # Number of mesh points
m1 <- GQD.mle(Xt,time,mesh=mesh.points,theta=theta.start)
GQD.remove()
G1 <- function(t){theta[1]*(theta[2]+theta[3]*sin(0.25*pi*t))}
G2 <- function(t){-theta[1]}
Q2 <- function(t){theta[4]*theta[4]}
theta.start <- c(1,1,1,1) # Starting values for the chain
mesh.points <- 10 # Number of mesh points
m2 <- GQD.mle(Xt,time,mesh=mesh.points,theta=theta.start)
# Check estimates:
GQD.estimates(m1)
GQD.estimates(m2)
# Compare models:
GQD.aic(list(m1,m2))
#===============================================================================
Run the code above in your browser using DataLab