Learn R Programming

SpatioTemporal (version 1.1.2)

estimate.STmodel: Estimation of the Spatio-Temporal Model

Description

Estimates parameters of the spatio-temporal model using maximum-likelihood, profile maximum likelihood or restricted maximum likelihood (REML). The function uses the L-BFGS-B method in optim to maximise loglikeST.

Usage

## S3 method for class 'STmodel':
estimate(object, x, x.fixed = NULL,
    type = "p", h = 0.001, diff.type = 1,
    hessian.all = FALSE, lower = -15, upper = 15,
    method = "L-BFGS-B",
    control = list(trace = 3, maxit = 1000), ...)

Arguments

object
STmodel object for which to estimate parameters.
x
Vector or matrix of starting point(s) for the optimisation. A vector will be treated as a single starting point. If x is a matrix the optimisation will be run using each column as a separate starting point. If x is a sin
x.fixed
Vector with parameter to be held fixed; parameters marked as NA will still be estimated.
type
A single character indicating the type of log-likelihood to use. Valid options are "f", "p", and "r", for full, profile or restricted maximum likelihood (REML).
h,diff.type
Step length and type of finite difference to use when computing gradients, see loglikeSTGrad.
hessian.all
If type!="f" computes hessian (and uncertainties) for both regression and log-covariance parameters, not only for log-covariance parameters. See value below.
lower,upper,method
Parameter bound and optimisation method, passed to optim.
control
A list of control parameters for the optimisation. See optim for details; setting trace=0 eliminates all ouput.
...
Ignored additional arguments.

Value

  • estimateSTmodel object containing:
  • res.bestA list containing the best optimisation result; elements are described below. Selection of the best result is described in details above.
  • res.allA list with all the optimisations results, each element contains (almost) the same information as res.best, e.g. res.all[[i]] contains optimisation results for the i:th starting point.
  • summaryA list with parameter estimates and convergence information for all starting points.

Details

The starting point(s) for the optimisation can either contain both regression parameters and log-covariances parameters for a total of loglikeSTdim(object)$nparam parameters or only contain the log-covariances covariances parameters i.e. loglikeSTdim(object)$nparam.cov parameters. If regression parameters are given but not needed (type!="f") they are dropped; if they are needed but not given they are inferred through a generalised least squares (GLS) computation, obtained by calling predict.STmodel.

If multiple starting points are used this function returns all optimisation results, along with an indication of the best result. The best result is determined by first evaluating which of the optimisations have converged. Convergence is determined by checking that the output from optim has convergence==0 and that the hessian is negative definite, i.e. all(eigen(hessian)$value < -1e-10). Among the converged optimisations the one with the highest log-likelihood value is then selected as the best result.

If none of the optimisations have converged the result with the highest log-likelihood value is selected as the best result.

Most of the elements in res.best (and in res.all[[i]]) are obtained from optim. The following is a brief description: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

See Also

Other estimateSTmodel methods: coef.estimateSTmodel, print.estimateSTmodel

Other STmodel methods: createSTmodel, c.STmodel, estimateCV.STmodel, MCMC.STmodel, plot.STdata, plot.STmodel, predictCV.STmodel, predict.STmodel, print.STmodel, print.summary.STmodel, simulate.STmodel, summary.STmodel

Examples

Run this code
##load a model object
data(mesa.model)

##examine the model
print(mesa.model)

##Important dimensions of the model
dim <- loglikeSTdim(mesa.model)
print(dim)

##Set up initial parameter values for optimization
x.init <- cbind(rep(2,dim$nparam.cov), c(rep(c(1,-3),dim$m+1),-3))
##and add names to the initial values
rownames(x.init) <- loglikeSTnames(mesa.model, all=FALSE)
print(x.init)
##estimate parameters
  ##This may take a while...
  est.mesa.model <- estimate(mesa.model, x.init, type="p", hessian.all=TRUE)
##Let's load precomputed results instead.
data(est.mesa.model)

##Optimisation status message
print(est.mesa.model)

##compare the estimated parameters for the two starting points
est.mesa.model$summary$par.all
##and values of the likelihood (and convergence info)
est.mesa.model$summary$status

##extract the estimated parameters and approximate uncertainties
x <- coef(est.mesa.model)

##plot the estimated parameters with uncertainties
par(mfrow=c(1,1),mar=c(13.5,2.5,.5,.5))
plot(x$par, ylim=range(c( x$par-1.96*x$sd, x$par+1.96*x$sd )),
     xlab="", xaxt="n")
points(x$par - 1.96*x$sd, pch=3)
points(x$par + 1.96*x$sd, pch=3)
axis(1, 1:length(x$par), rownames(x), las=2)

##fixed pars
  x.fixed <- coef(est.mesa.model)$par
  x.fixed[c(1,2,5:9)] <- NA
  est.fix <- estimate(mesa.model, x.init, x.fixed, type="p")

Run the code above in your browser using DataLab