neglogLik {PtProcess}R Documentation

Negative Log-Likelihood

Description

Calculates the log-likelihood multiplied by negative one. It is in a format that can be used with the functions nlm and optim.

Usage

neglogLik(params, object, pmap)

Arguments

params a vector of revised parameter values.
object an object of class "mpp".
pmap a user provided function mapping the revised parameter values params into the appropriate locations in object.

Details

This function can be used with the two functions nlm and optim (see “Examples” below) to maximise the likelihood function of a model specified in object. Both nlm and optim are minimisers, hence the “negative” log-likelihood. The topic distribution gives examples of their use in the relatively easy situation of fitting standard probability distributions to data assuming independence.

The maximisation of the model likelihood function can be restricted to be over a subset of the model parameters. Other parameters will then be fixed at the values stored in the model object. Let Theta_0 denote the full model parameter space, and let Theta denote the parameter sub-space (Theta subseteq Theta_0) over which the likelihood function is to be maximised. The argument params contains values in Theta, and pmap is assigned a function that maps these values into the full model parameter space Theta_0. See “Examples” below.

The mapping function assigned to pmap can also be made to impose restrictions on the domain of the parameter space Theta so that the minimiser cannot jump to values such that Theta notsubseteq Theta_0. For example, if a particular parameter must be positive, one can work with a transformed parameter that can take any value on the real line, with the model parameter being the exponential of this transformed parameter. Similarly a modified logit like transform can be used to ensure that parameter values remain within a fixed interval with finite boundaries. Examples of these situations can be found in the topic distribution and the “Examples” below.

Value

Value of the log-likelihood times negative one.

See Also

nlm, optim

Examples

#    SRM: magnitude is iid exponential with bvalue=1
#    maximise exponential mark density too

TT <- c(0, 1000)
bvalue <- 1
params <- c(-2.5, 0.01, 0.8, bvalue*log(10))

x <- mpp(data=NULL,
         gif=srm_gif,
         mark=list(dexp_mark, rexp_mark),
         params=params,
         gmap=expression(params[1:3]),
         mmap=expression(params[4]),
         TT=TT)
x <- simulate(x, seed=5)

allmap <- function(y, p){
    #    map all parameters into model object
    #    transform exponential param so it is positive
    y$params[1:3] <- p[1:3]
    y$params[4] <- exp(p[4])
    return(y)
}

params <- c(-2.5, 0.01, 0.8, log(bvalue*log(10)))

z <- nlm(neglogLik, params, object=x, pmap=allmap,
         print.level=2, iterlim=500, typsize=abs(params))
print(z$estimate)

#   these should be the same:
print(exp(z$estimate[4]))
print(1/mean(x$data$magnitude))

[Package PtProcess version 3.1-3 Index]