# Loading datasets
data(simple)
head(simple)
################################################
# Time delay estimation via profile likelihood #
################################################
###### Individual profile likelihood value
theta.ini = c(0, 0.03, 100)
c.ini <- mean(simple[, 4]) - mean(simple[, 2])
delta.uniform.range <- c(0, 100)
### Running the following codes takes more time than CRAN policy
### Please type the following two lines without "#" to run the function
# logprofilelikelihood(Delta = 40, initial = c(theta.ini, c.ini), data = simple,
# data.flux = FALSE, delta.uniform.range = delta.uniform.range)
###### Maximum profile likelihood estimate and
###### the inverse of the negative Hessian value at the mode
# prof.lik <- function(delta) {
# logprofilelikelihood(delta, initial = c(theta.ini, c.ini), data = simple,
# data.flux = FALSE, delta.uniform.range = delta.uniform.range)
# }
# outcome <- optim(50, prof.lik, control = list(fnscale = -1), method = "BFGS", hessian = TRUE)
# maximum profile likelihood estimate:
# outcome$par
# inverse of the negative Hessian value at the mode:
# 1 / sqrt(-outcome$hessian)Run the code above in your browser using DataLab