predict_spm {smile} | R Documentation |
Prediction over the same or a different set of regions (or points).
Description
Realizes predictions that can be useful when researchers are interested in predict a variable observed in one political division of a city (or state) on another division of the same region.
Usage
predict_spm(x, ...)
## S3 method for class 'spm_fit'
predict_spm(x, .aggregate = TRUE, ...)
## S3 method for class 'sf'
predict_spm(x, spm_obj, n_pts, type, outer_poly = NULL, id_var, ...)
Arguments
x |
a |
... |
additional parameters |
.aggregate |
|
spm_obj |
an object of either class |
n_pts |
a |
type |
|
outer_poly |
(object) |
id_var |
if |
Value
a list
of size 4 belonging to the class spm_pred
. This
list contains the predicted values and the mean and covariance matrix
associated with the conditional distribution used to compute the
predictions.
Examples
data(liv_lsoa) ## loading the LSOA data
data(liv_msoa) ## loading the MSOA 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))
pred_lsoa <- predict_spm(x = liv_lsoa, spm_obj = fit_msoa, id_var = "lsoa11cd")