Last chance! 50% off unlimited learning
Sale ends in
loglike
uses an optimised version of the log-likelihood, while
loglike.naive
uses the naive (slow) version and is included
mainly for testing and speed checks.loglike(x = NA, mesa.data.model, type = "p")loglike.naive(x = NA, mesa.data.model, type = "p")
type=c("p","r")
and
regression parameters followed by log-covariance parameters
if type="f"
. If x=NA
create.data.model
and
If x = NA
it returns reasonable parameter names, by calling
loglike.var.names(mesa.data.model, all=(type=="f"))
.
loglike.naive
may take long to run. However for some
problems with many locations and short time series loglike.naive
can be faster than loglike
.x
are given by
loglike.var.names
, with loglike.dim
giving
number of parameters. Gradients and Hessian of the log-likelihood are computed by
loglike.grad
and
loglike.hessian
.
For optimization functions see create.data.model
,
run.MCMC
, fit.mesa.model
, and
cond.expectation
.
##load the data
data(mesa.data.model)
##Compute dimensions for the data structure
dim <- loglike.dim(mesa.data.model)
##Find out in which order parameters should be given
loglike(NA,mesa.data.model)
##Let's create random vectors of values
x <- runif(dim$nparam.cov)
x.all <- runif(dim$nparam)
##Evaluate the log-likelihood for these values
loglike(x.all, mesa.data.model, "f")
loglike(x, mesa.data.model, "p")
loglike(x, mesa.data.model, "r")
##check that profile and full give the same results
data(mesa.data.res)
x.all <- mesa.data.res$par.est$res.best$par.all
x <- mesa.data.res$par.est$res.best$par
if( abs(loglike(x.all, mesa.data.model, "f") -
loglike(x, mesa.data.model, "p")) > 1e-8 ){
stop("loglike: full and profile not equal")
}
Run the code above in your browser using DataLab