## simulated data of an IHSEP on [0,1] with baseline intensity function
## nu(t)=200*(2+cos(2*pi*t)) and excitation function
## g(t)=8*exp(-16*t)
data(asep)
## get the birth times of all generations and sort in ascending order
tms <- sort(unlist(asep))
## calculate the minus loglikelihood of an SEPP with the true parameters
mloglik1d(tms,TT=1,nu=function(x)200*(2+cos(2*pi*x)),
gcoef=8*1:2,
Inu=function(y)integrate(function(x)200*(2+cos(2*pi*x)),0,y)$value)
## calculate the MLE for the parameter assuming known parametric forms
## of the baseline intensity and excitation functions
if (FALSE) {
system.time(est <- optim(c(400,200,2*pi,8,16),
function(p){
mloglik1d(jtms=tms,TT=1,
nu=function(x)p[1]+p[2]*cos(p[3]*x),
gcoef=p[-(1:3)],
Inu=function(y){
integrate(function(x)p[1]+p[2]*cos(p[3]*x),
0,y)$value
})
},hessian=TRUE,control=list(maxit=5000,trace=TRUE),
method="BFGS")
)
## point estimate by MLE
est$par
## standard error estimates:
diag(solve(est$hessian))^0.5
}
Run the code above in your browser using DataLab