Description Usage Arguments Details Value Examples
View source: R/krylov_neg_loglik.R
The function krylov_neg_loglik
is used to calculate the approximate negative log-likelihood function by Krylov methods.
1 2 3 |
theta |
the vector of covariance parameters. |
y |
response variable. |
X |
the model matrix. |
dist_mat |
the distance matrix. |
cov.model |
a quoted keyword that specifies the covariance function used to model the spatial dependence structure among the observations. Supported keywords are: |
cov.taper |
cov.taper a quoted keyword that specifies the tapering function. Supported keywords are: |
delta |
tapering threshold parameter. |
ctrl |
A list of control parameters. See 'Details'. |
gls |
If |
nu |
the smooth parameter for the Matern covariance function. |
The ctrl
argument is a list that can supply any of the following components:
convergence tolerance for the conjugate gradient algorithm.
maximum number of iterations for the conjugate gradient algorithm.
a quoted keyword that specifies preconditioner. Supported keywords are:
"no_precond"
,"ICHOL0"
,"ILUT"
,"Jacobi"
,"row scaling"
,
"ILU0"
,"Block-ILU0"
and "Block-ILUT"
.
the order of the Gaussian quadrature rule.
the number of Monte Carlo iterations.
random seed.
the negative log-likelihood.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | library(spKrylov)
library(foreach)
library(spam)
set.seed(2019)
n <- 70^2 # sample size
delta <- 6 # only distances smaller than delta are recorded.
rep <- 1
data("sim_n_4900rep_1delta_6")
theta <- c(2, 0.2)
dist_mat <- nearest.dist(train[, 1:2],
miles = FALSE,
upper = NULL,
delta = delta
)
#########################################################
### Approximate Negative Log-likelihood by Krylov Method
#########################################################
system.time(
lik2 <- krylov_neg_loglik(
theta = theta,
y = train[, 3],
dist_mat = dist_mat,
cov.model = "exponential",
cov.taper = "wend1",
delta = delta,
ctrl = list(
cg.tol = 1e-6, cg.max_iter = 1000,
cg.precond = "no_precond",
logdet.m = 50, logdet.nr = 1
),
gls = FALSE
)
)
lik2
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.