NSconvo_fit
estimates the parameters of the nonstationary
convolution-based spatial model. Required inputs are the observed data and
locations. Optional inputs include mixture component locations (if not provided,
the number of mixture component locations are required), the fit radius,
the covariance model (exponential is the default), and whether or not the
nugget and process variance will be spatially-varying.
NSconvo_fit(
sp.SPDF = NULL,
coords = NULL,
data = NULL,
cov.model = "exponential",
mean.model = data ~ 1,
mc.locations = NULL,
N.mc = NULL,
lambda.w = NULL,
fixed.nugg2.var = NULL,
mean.model.df = NULL,
mc.kernels = NULL,
fit.radius = NULL,
ns.nugget = FALSE,
ns.variance = FALSE,
ns.mean = FALSE,
local.aniso = TRUE,
fix.tausq = FALSE,
tausq = 0,
fix.kappa = FALSE,
kappa = 0.5,
method = "reml",
print.progress = TRUE,
local.pars.LB = NULL,
local.pars.UB = NULL,
global.pars.LB = NULL,
global.pars.UB = NULL,
local.ini.pars = NULL,
global.ini.pars = NULL
)
A "SpatialPointsDataFrame
" object, which contains the
spatial coordinates and additional attribute variables corresponding to the
spatoal coordinates
An N x 2 matrix where each row has the two-dimensional coordinates of the N data locations.
A vector or matrix with N rows, containing the data values. Inputting a vector corresponds to a single replicate of data, while inputting a matrix corresponds to replicates. In the case of replicates, the model assumes the replicates are independent and identically distributed.
A string specifying the model for the correlation
function; defaults to "exponential"
.
Options available in this package are: "exponential
",
"matern"
, and "gaussian"
.
An object of class formula
,
specifying the mean model to be used. Defaults to an intercept only.
Optional; matrix of mixture component locations.
Optional; if mc.locations
is not specified, the
function will create a rectangular grid of size N.mc
over the
spatial domain.
Scalar; tuning parameter for the weight function. Defaults to be the square of one-half of the minimum distance between mixture component locations.
Optional; describes the variance/covariance for a fixed (second) nugget term (represents a known error term). Either a vector of length N containing a station-specific variances (implying independent error) or an NxN covariance matrix (implying dependent error). Defaults to zero.
Optional data frame; refers to the variables used
in mean.model
. Important when using categorical variables in
mean.model
, as a subset of the full design matrix will likely
be rank deficient. Specifying mean.model.df
allows NSconvo_fit
to calculate a design matrix specific to the points used to fit each
local model.
Optional specification of mixture component kernel matrices (based on expert opinion, etc.).
Scalar; specifies the fit radius or neighborhood size for the local likelihood estimation.
Logical; indicates if the nugget variance (tausq) should
be spatially-varying (TRUE
) or constant (FALSE
).
Logical; indicates if the process variance (sigmasq)
should be spatially-varying (TRUE
) or constant (FALSE
).
Logical; indicates if the mean coefficeints (beta)
should be spatially-varying (TRUE
) or constant (FALSE
).
Logical; indicates if the local covariance should be
anisotropic (TRUE
) or isotropic (FALSE
). Defaults to TRUE
.
In the case of a locally isotropic model, the bounds and initial values
for lam will default to the first element of local.pars.LB
,
local.pars.UB
, and local.ini.pars
(while still required, the
second and third elements of these vectors will be ignored.)
Logical; indicates whether the default nugget term
(tau^2) should be fixed (TRUE
) or estimated (FALSE
). Defaults to
FALSE
.
Scalar; fixed value for the nugget variance (when
fix.tausq = TRUE
).
Logical; indicates if the kappa parameter should be
fixed (TRUE
) or estimated (FALSE
). Defaults to FALSE
(only valid for cov.model = "matern"
and cov.model = "cauchy"
).
Scalar; value of the kappa parameter. Only used if
fix.kappa = TRUE
.
Indicates the estimation method, either maximum likelihood
("ml"
) or restricted maximum likelihood ("reml"
).
Logical; if TRUE
, text indicating the progress
of local model fitting in real time.
Optional vectors of lower and upper
bounds, respectively, used by the "L-BFGS-B"
method option in the
optim
function for the local parameter estimation.
Each vector must be of length five,
containing values for lam1, lam2, tausq, sigmasq, and nu. Default for
local.pars.LB
is rep(1e-05,5)
; default for
local.pars.UB
is c(max.distance/2, max.distance/2, 4*resid.var, 4*resid.var, 100)
,
where max.distance
is the maximum interpoint distance of the
observed data and resid.var
is the residual variance from using
lm
with mean.model
.
Optional vectors of lower and upper
bounds, respectively, used by the "L-BFGS-B"
method option in the
optim
function for the global parameter estimation.
Each vector must be of length three,
containing values for tausq, sigmasq, and nu. Default for
global.pars.LB
is rep(1e-05,3)
; default for
global.pars.UB
is c(4*resid.var, 4*resid.var, 100)
,
where resid.var
is the residual variance from using
lm
with mean.model
.
Optional vector of initial values used by the
"L-BFGS-B"
method option in the optim
function for the local parameter estimation. The vector must be of length
five, containing values for lam1, lam2, tausq, sigmasq, and nu. Defaults
to c(max.distance/10, max.distance/10, 0.1*resid.var, 0.9*resid.var, 1)
,
where max.distance
is the maximum interpoint distance of the
observed data and resid.var
is the residual variance from using
lm
with mean.model
.
Optional vector of initial values used by the
"L-BFGS-B"
method option in the optim
function for the global parameter estimation. The vector must be of length
three, containing values for tausq, sigmasq, and nu. Defaults to
c(0.1*resid.var, 0.9*resid.var, 1)
, where resid.var
is the
residual variance from using lm
with mean.model
.
A "NSconvo" object, with the following components:
Mixture component locations used for the simulated data.
Mixture component kernel matrices used for the simulated data.
Table of local maximum likelihood estimates for each mixture component location.
N.obs
x 2 x 2 array, containing the kernel
matrices corresponding to each of the simulated values.
Observed data values.
Generalized least squares estimates of beta,
the mean coefficients. For ns.mean = FALSE
, this is a vector
(containing the global mean coefficients); for ns.mean = TRUE
,
this is a matrix (one column for each mixture component location).
Covariance matrix of the generalized least squares
estimate of beta. For ns.mean = FALSE
, this is a matrix
(containing the covariance of theglobal mean coefficients); for
ns.mean = TRUE
, this is an array (one matrix for each mixture
component location).
"Regression table" for the mean coefficient estimates,
listing the estimate, standard error, and t-value (for ns.mean =
FALSE
only).
Estimate of tausq (nugget variance), either scalar (when
ns.nugget = "FALSE"
) or a vector of length N (when
ns.nugget = "TRUE"
), which contains the estimated nugget variance
for each observation location.
Estimate of sigmasq (process variance), either scalar
(when ns.variance = "FALSE"
) or a vector of length N (when
ns.variance = "TRUE"
), which contains the estimated process
variance for each observation location.
Estimate of beta (mean coefficients), either a vector
(when ns.mean = "FALSE"
) or a matrix with N rows (when
ns.mean = "TRUE"
), each row of which contains the estimated
(smoothed) mean coefficients for each observation location.
Scalar maximum likelihood estimate for kappa (when applicable).
Estimated covariance matrix (N.obs
x N.obs
)
using all relevant parameter estimates.
Cholesky of Cov.mat
(i.e., chol(Cov.mat)
),
the estimated covariance matrix (N.obs
x N.obs
).
String; the correlation model used for estimation.
Logical, indicating if the nugget variance was estimated
as spatially-varing (TRUE
) or constant (FALSE
).
Logical, indicating if the process variance was
estimated as spatially-varying (TRUE
) or constant (FALSE
).
N x N matrix with the fixed variance/covariance for the second (measurement error) nugget term (defaults to zero).
N x 2 matrix of observation locations.
Scalar value of the maximized likelihood from the global optimization (if available).
Design matrix, obtained from using lm
with mean.model
.
Tuning parameter for the weight function.
Logical, indicating if kappa was fixed (TRUE
) or
estimated (FALSE
).
Scalar; fixed value of kappa.
# NOT RUN {
# Using white noise data
fit.model <- NSconvo_fit( coords = cbind( runif(100), runif(100)),
data = rnorm(100), fit.radius = 0.4, N.mc = 4 )
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab