Learn R Programming

cocons (version 0.1.5)

cocoOptim: Optimizer for coco objects

Description

Estimation the spatial model parameters using the L-BFGS-B optimizer [1].

Usage

cocoOptim(coco.object, boundaries = list(), ncores = "auto", safe = TRUE,
optim.type, optim.control)

Value

(S4) An optimized S4 object of class coco.

Arguments

coco.object

(S4) A coco object.

boundaries

(list) If provided, a list containing lower, initial, and upper values for the parameters, as defined by getBoundaries. If not provided, these values are automatically computed via getBoundariesV4 with global lower and upper bounds set to -3 and 3.

ncores

(character or integer) The number of threads to use for the optimization. If set to "auto", the number of threads is chosen based on system capabilities or a fraction of the available cores.

safe

(logical) If TRUE, the function avoids Cholesky decomposition errors due to ill-posed covariance matrices by returning a pre-defined large value. Defaults to TRUE.

  • "ml": Classical Maximum Likelihood estimation.

  • "pml": Profile Maximum Likelihood, factoring out the spatial trend for dense objects or the global marginal variance parameter for sparse objects.

optim.type

(character) The optimization approach. Options include:

optim.control

(list) A list of settings to be passed to the optimParallel function [2].

Author

Federico Blasi

References

[1] Byrd, Richard H., et al. "A limited memory algorithm for bound constrained optimization." SIAM Journal on scientific computing 16.5 (1995): 1190-1208.

[2] Gerber, Florian, and Reinhard Furrer. "optimParallel: An R package providing a parallel version of the L-BFGS-B optimization method." R Journal 11.1 (2019): 352-358.

See Also

[optimParallel]

Examples

Run this code
if (FALSE) {
model.list <- list('mean' = 0,
                   'std.dev' = formula( ~ 1 + cov_x + cov_y),
                   'scale' = formula( ~ 1 + cov_x + cov_y),
                   'aniso' = 0,
                   'tilt' = 0,
                   'smooth' = 3/2,
                   'nugget' = -Inf)
                   
sample_index <- sample(1:dim(holes[[1]])[1],200)
                   
coco_object <- coco(type = 'dense',
                    data = holes[[1]][sample_index, ],
                    locs = as.matrix(holes[[1]][sample_index,1:2]),
                    z = holes[[1]][sample_index, ]$z,
                    model.list = model.list)
                    
optim_coco <- cocoOptim(coco_object,
boundaries = getBoundaries(coco_object,-3,3))

plotOptimInfo(optim_coco)

plot(optim_coco)

plot(optim_coco, type = 'ellipse')

plot(optim_coco, type = 'correlations', index = c(2,3,5))

summary(optim_coco,inv.hess = getHessian(optim_coco))
 
getEstims(optim_coco)

}

Run the code above in your browser using DataLab