choleskyFactory {GeneralizedWendland} | R Documentation |
Function Factory for Generating chol Function with unified arguments
Description
A function factory which returns a function of the form function(Sigma)
which performs a cholesky decomposition using an approach tailored to the type of input Sigma. Currently works for vectors, matrices, spam objects, and dgCMatrix objects from the Matrix package.
Usage
choleskyFactory(chol.args = list(), Rstruct = NULL)
Arguments
chol.args |
A list of optional settings for a cholesky function. |
Rstruct |
A |
Details
The output of choleskyFactory
is intended to replace calls to chol.default
or chol.spam
. The object type is determined during runtime, after which the appropriate function is called to obtain the cholesky decomposition. For spam objects, the function attempts to use update.spam.chol.NgPeyton
if Rstruct
is specified, and upon failure defaults to chol.spam
. The result is then assigned in the execution environment of choleskyFactory
, so that Rstruct
will be defined in the next call.
Value
A function of the form function(Sigma)
.
Author(s)
Thomas Caspar Fischer
References
Hadley Wickham (2015) Advanced R, CRC Press. Reinhard Furrer and Roman Flury and Florian Gerber (2022) spam: SPArse Matrix, R package version 2.8-0.
See Also
chol
,
chol.spam
,
update.spam.chol.NgPeyton
Examples
set.seed(1234)
locations <- data.frame(x = runif(10), y = runif(10))
theta <- c(0.5,1,1,0,0)
dmat <- as.matrix(dist(locations))
Sigma <- cov.wendland(dmat, theta)
cholFun <- choleskyFactory(chol.args = list())
cholD <- cholFun(Sigma)
cholFun <- choleskyFactory(chol.args = list(pivot = TRUE))
cholD_pivot <- cholFun(Sigma)
cholFun <- choleskyFactory(chol.args = list(pivot = "RCM"))
cholS_RCM <- cholFun(spam::as.spam(Sigma))