BGL: Basis Graphical Lasso

Description Usage Arguments Details Value Examples

View source: R/BGL.R

Description

Estimates the precision matrix from the basis graphical lasso model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
BGL(
  y,
  locs,
  lambda,
  zero.diagonal.penalty = TRUE,
  basis = "LatticeKrig",
  Phi = NULL,
  guess = NULL,
  outer_tol = NULL,
  MAX_ITER = NULL,
  MAX_RUNTIME_SECONDS = NULL,
  tau_sq = NULL,
  verbose = TRUE,
  distance.penalty = FALSE,
  ...
)

Arguments

y

Real-valued data matrix of dimension (number of spatial locations) x (number of realizations).

locs

Matrix of real-valued spatial locations of data of dimension (number of spatial locations) x 2.

lambda

Penalty parameter. Can be either a nonnegative real, or a matrix of nonnegative reals whose dimension is the same as the number of graph nodes.

zero.diagonal.penalty

Boolean. If TRUE with a scalar penalty lambda, then diagonals of the precision matrix are not penalized, Default: TRUE.

basis

Character string for type of basis desired, currently only supports LatticeKrig-type basis.

Phi

Basis matrix, if not specified in basis option. Rows index location and columns index basis function, Default: NULL.

guess

An initial guess at the precision matrix. Default: identity matrix.

outer_tol

Tolerance. Default: see BGL_DC.

MAX_ITER

Maximum number of iterations. Default: see BGL_DC.

MAX_RUNTIME_SECONDS

Maximum runtime in seconds. Default: see BGL_DC.

tau_sq

Nugget variance, estimated by nugget_estimate if not provided.

verbose

Print algorithm details after each iteration. Default: TRUE.

distance.penalty

If using LatticeKrig Wendland basis functions and a constant lambda, then multiply the distance matrix of the basis centers times lambda for the penalty matrix, Default: FALSE.

...

Other options relevant for basis specification such as NC and nlevel for LatticeKrig-type bases.

Details

This takes the data itself as input, along with choices or inputs for basis function and nugget variance, and appropriately sends it to the main algorithm in the paper.

Value

Precision matrix of the random coefficients in the weighted sum of basis functions, and estimated (or provided) nugget variance.

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
precision.fit <- BGL(y=tmin$data, locs=tmin$lon.lat.proj, lambda=7, basis="LatticeKrig",
    distance.penalty=TRUE,outer_tol=5e-2, MAX_ITER=50,
    MAX_RUNTIME_SECONDS=86400, NC=20, nlevel=1)
    
 # The estimate in paper, with the tolerance set to 1e-2 not 5e-2 and NC=30 not NC=20.
 # Takes a few minutes longer than the version above
 # precision.fit <- BGL(y=tmin$data, locs=tmin$lon.lat.proj, lambda=7, basis="LatticeKrig",
    # distance.penalty=TRUE,outer_tol=1e-2, MAX_ITER=50,
    # MAX_RUNTIME_SECONDS=86400, NC=30, nlevel=1)
    
# Plot standard errors
cholQ <- chol(precision.fit$Q)
Phi <- precision.fit$Phi
marginal_variances <- rep(NA,dim(Phi)[1])
for(i in 1:dim(Phi)[1])
{
    marginal_variances[i] <- norm(backsolve(cholQ,Phi[i,],transpose=TRUE) ,type="F")^2
}
quilt.plot(tmin$lon.lat.proj,sqrt(marginal_variances), 
     main="Estimated process standard deviation")      
     
# A (noisy) simulation
c_coef <- backsolve(cholQ,rnorm(dim(Phi)[2])) 
sim <- Phi %*% c_coef + sqrt(precision.fit$nugget_variance)*rnorm(dim(Phi)[1])
quilt.plot(tmin$lon.lat.proj,sim,main="Simulation")     

mlkrock/BasisGraphicalLasso documentation built on Dec. 21, 2021, 7:59 p.m.