choleskyFactory | R Documentation |
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.
choleskyFactory(chol.args = list(), Rstruct = NULL)
chol.args |
A list of optional settings for a cholesky function. |
Rstruct |
A |
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.
A function of the form function(Sigma)
.
Thomas Caspar Fischer
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.
chol
,
chol.spam
,
update.spam.chol.NgPeyton
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.