krylov_neg_loglik: The function 'krylov_neg_loglik' is used to calculate the...

Description Usage Arguments Details Value Examples

View source: R/krylov_neg_loglik.R

Description

The function krylov_neg_loglik is used to calculate the approximate negative log-likelihood function by Krylov methods.

Usage

1
2
3
krylov_neg_loglik(theta = c(2, 0.2), y, X = NULL, dist_mat,
  cov.model = "exponential", cov.taper = "wend1", delta = 2,
  ctrl = list(), gls = FALSE, nu = NULL)

Arguments

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: "exponential", "matern" and "spherical".

cov.taper

cov.taper a quoted keyword that specifies the tapering function. Supported keywords are: "spherical", "wend1" and "wend2".

delta

tapering threshold parameter.

ctrl

A list of control parameters. See 'Details'.

gls

If gls==TURE, use generalized least square method. Otherwise, use ordinary least square method.

nu

the smooth parameter for the Matern covariance function.

Details

The ctrl argument is a list that can supply any of the following components:

cg.tol

convergence tolerance for the conjugate gradient algorithm.

cg.max_iter

maximum number of iterations for the conjugate gradient algorithm.

cg.precond

a quoted keyword that specifies preconditioner. Supported keywords are: "no_precond","ICHOL0","ILUT","Jacobi","row scaling", "ILU0","Block-ILU0" and "Block-ILUT".

logdet.m

the order of the Gaussian quadrature rule.

logdet.nr

the number of Monte Carlo iterations.

rad.seed

random seed.

Value

the negative log-likelihood.

Examples

 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

liujl93/spKrylov documentation built on Aug. 26, 2020, 8:46 p.m.