fit_model {GpGp} | R Documentation |
Estimate mean and covariance parameters
Description
Given a response, set of locations, (optionally) a design matrix, and a specified covariance function, return the maximum Vecchia likelihood estimates, obtained with a Fisher scoring algorithm.
Usage
fit_model(
y,
locs,
X = NULL,
covfun_name = "matern_isotropic",
NNarray = NULL,
start_parms = NULL,
reorder = TRUE,
group = TRUE,
m_seq = c(10, 30),
max_iter = 40,
fixed_parms = NULL,
silent = FALSE,
st_scale = NULL,
convtol = 1e-04
)
Arguments
y |
response vector |
locs |
matrix of locations. Each row is a single spatial or spatial-temporal location. If using one of the covariance functions for data on a sphere, the first column should be longitudes (-180,180) and the second column should be latitudes (-90,90). If using a spatial-temporal covariance function, the last column should contain the times. |
X |
design matrix. Each row contains covariates for the corresponding
observation in |
covfun_name |
string name of a covariance function.
See |
NNarray |
Optionally specified array of nearest neighbor indices,
usually from the output of |
start_parms |
Optionally specified starting values for parameters.
If |
reorder |
TRUE/FALSE indicating whether maxmin ordering should be used
(TRUE) or whether no reordering should be done before fitting (FALSE).
If you want
to use a customized reordering, then manually reorder |
group |
TRUE/FALSE for whether to use the grouped version of the approximation (Guinness, 2018) or not. The grouped version is used by default and is always recommended. |
m_seq |
Sequence of values for number of neighbors. By default,
a 10-neighbor
approximation is maximized, then a 30-neighbor approximation is
maximized using the
10 neighbor estimates as starting values.
However, one can specify any sequence
of numbers of neighbors, e.g. |
max_iter |
maximum number of Fisher scoring iterations |
fixed_parms |
Indices of covariance parameters you would like to fix
at specific values. If you decide to fix any parameters, you must specify
their values in |
silent |
TRUE/FALSE for whether to print some information during fitting. |
st_scale |
Scaling for spatial and temporal ranges. Only applicable for
spatial-temporal models, where it is used in distance
calculations when selecting neighbors. |
convtol |
Tolerance for exiting the optimization.
Fisher scoring is stopped
when the dot product between the step and the gradient
is less than |
Details
fit_model
is a user-friendly model fitting function
that automatically performs many of the auxiliary tasks needed for
using Vecchia's approximation, including reordering, computing
nearest neighbors, grouping, and optimization. The likelihoods use a small
penalty on small nuggets, large spatial variances,
and small smoothness parameter.
The Jason-3 windspeed vignette and the Argo temperature
vignette are useful sources for a
use-cases of the fit_model
function for data on sphere.
The example below shows a very small example with a simulated dataset in 2d.
Value
An object of class GpGp_fit
, which is a list containing
covariance parameter estimates, regression coefficients,
covariance matrix for mean parameter estimates, as well as some other
information relevant to the model fit.
Examples
n1 <- 20
n2 <- 20
n <- n1*n2
locs <- as.matrix( expand.grid( (1:n1)/n1, (1:n2)/n2 ) )
covparms <- c(2,0.1,1/2,0)
y <- 7 + fast_Gp_sim(covparms, "matern_isotropic", locs)
X <- as.matrix( rep(1,n) )
## not run
# fit <- fit_model(y, locs, X, "matern_isotropic")
# fit