krylov_mle: The function 'krylov_mle' is used to fit spatial regression...

Description Usage Arguments Details Value Examples

View source: R/krylov_mle.R

Description

The function krylov_mle is used to fit spatial regression models.

Usage

1
2
3
4
krylov_mle(y, X = NULL, dist_mat, cov.model = "exponential",
  cov.taper = "wend1", theta.init = c(2, 0.2), theta.lower = c(1e-04,
  0), theta.upper = c(2, 1), delta = 2, ctrl = list(), gls = FALSE,
  nu = NULL)

Arguments

y

the 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".

theta.init

numeric vector, initial values for the covariance parameters to be optimized.

theta.lower

vector of lower limit of covariance parameters.

theta.upper

vector of upper limit of covariance parameters.

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

A list with components:

result

A list consists of the regression coefficient beta, the covariance parameter theta, and the solution to the linear system z=Γ^{-1}(y-Xβ) at the kth iteration.

conv

An integer code. 0 indicates successful convergence.

neg.loglik

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
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")
nr <- 1

dist_mat <- nearest.dist(train[, 1:2],
  miles = FALSE,
  upper = NULL,
  delta = delta
)

system.time(
  fit.mle <- krylov_mle(
    y = train[, 3],
    dist_mat = dist_mat,
    cov.model = "exponential",
    cov.taper = "wend1",
    theta.init = c(3, 0.15),
    theta.lower = c(0.0001, 0.0001),
    theta.upper = c(max(dist_mat), 1),
    delta = delta,
    ctrl = list(
      cg.tol = 1e-6, cg.max_iter = 1000,
      cg.precond = "no_precond",
      logdet.m = 30, logdet.nr = nr
    ),
    gls = FALSE
  )
)

fit.mle$result$theta

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