fit_spm | R Documentation |
Fitting an underlying continuous process to areal data
fit_spm(x, ...)
## S3 method for class 'spm'
fit_spm(
x,
model,
theta_st,
nu = NULL,
tr = NULL,
kappa = 1,
mu2 = 1.5,
apply_exp = FALSE,
opt_method = "Nelder-Mead",
control_opt = list(),
comp_hess = TRUE,
...
)
fit_spm2(
x,
model,
nu,
tr,
kappa = 1,
mu2 = 1.5,
comp_hess = TRUE,
phi_min,
phi_max,
nphi = 10,
cores = getOption("mc.cores", 1L)
)
x |
an object of type |
... |
additional parameters, either passed to stats::optim. |
model |
a |
theta_st |
a |
nu |
a |
tr |
tapper range |
kappa |
|
mu2 |
the smoothness parameter |
apply_exp |
a |
opt_method |
a |
control_opt |
a named |
comp_hess |
a |
phi_min |
a |
phi_max |
a |
nphi |
a |
cores |
a |
This function uses the stats::optim function optimization
algorithms to find the Maximum Likelihood estimators, and their standard
errors, from a model adapted from. The function allows the user to input
the control parameters from the stats::optim function through the argument
control_opt
, which is a named list. Additionally, the one can
input lower and upper boundaries for the optimization problem, as well
as the preferred optimization algorithm (as long as it is available for
stats::optim). The preferred algorithm is selected by the argument
opt_method
. In addition to the control of the optimization, the
user can select a covariance function among the following: Matern,
Exponential, Powered Exponential, Gaussian, and Spherical. The parameter
apply_exp
is a logical
scalar such that, if set to
TRUE
, the \exp
function is applied to the nonnegative
parameters, allowing the optimization algorithm to search for all the
parameters over the real numbers.
The model assumes \deqn{Y(\mathbf{s}) = \mu + S(\mathbf{s})} at the point level. Where \eqn{S ~ GP(0, \sigma^2 C(\lVert \mathbf{s} - \mathbf{s}_2 \rVert; \theta))}. Further, the observed data is supposed to be \eqn{Y(B) = \lvert B \rvert^{-1} \int_{B} Y(\mathbf{s}) \, \textrm{d} \mathbf{s}}.
a spm_fit
object containing the information about the
estimation of the model parameters.
data(liv_lsoa) ## loading the LSOA data
msoa_spm <- sf_to_spm(sf_obj = liv_msoa, n_pts = 500,
type = "regular", by_polygon = FALSE,
poly_ids = "msoa11cd",
var_ids = "leb_est")
## fitting model
theta_st_msoa <- c("phi" = 1) # initial value for the range parameter
fit_msoa <-
fit_spm(x = msoa_spm,
theta_st = theta_st_msoa,
model = "matern",
nu = .5,
apply_exp = TRUE,
opt_method = "L-BFGS-B",
control = list(maxit = 500))
AIC(fit_msoa)
summary_spm_fit(fit_msoa, sig = .05)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.