nll <- function(par) {
getAll(par, dat)
Gamma <- tpm(eta)
mu <- exp(log_mu); REPORT(mu)
allprobs <- cbind(dgamma2(step, mu[1], exp(log_sigma[1])),
dgamma2(step, mu[2], exp(log_sigma[2])))
-forward(stationary(Gamma), Gamma, allprobs)
}
dat <- list(step = trex$step[1:500])
par <- list(eta = c(-2, -2), log_mu = log(c(0.3, 2.5)), log_sigma = log(c(0.2, 1.5)))
obj <- MakeADFun(nll, par, silent = TRUE)
opt <- multistart(obj, seed = 1)
opt$runs
mod <- lama(obj) # best fit
# starts scaled by the first fit
opt <- multistart(obj, scale = "unit_info", seed = 1)
Run the code above in your browser using DataLab