predict.SVC_mle: Prediction of SVCs (and response variable) In varycoef: Modeling Spatially Varying Coefficients

 predict.SVC_mle R Documentation

Prediction of SVCs (and response variable)

Description

Prediction of SVCs (and response variable)

Usage

```## S3 method for class 'SVC_mle'
predict(
object,
newlocs = NULL,
newX = NULL,
newW = NULL,
newdata = NULL,
compute.y.var = FALSE,
...
)
```

Arguments

 `object` (`SVC_mle`) Model obtained from `SVC_mle` function call. `newlocs` (`NULL` or `matrix(n.new, 2)`) If `NULL`, then function uses observed locations of model to estimate SVCs. Otherwise, these are the new locations the SVCs are predicted for. `newX` (`NULL` or `matrix(n.new, q)`) If provided (together with `newW`), the function also returns the predicted response variable. `newW` (`NULL` or `matrix(n.new, p)`) If provided (together with `newX`), the function also returns the predicted response variable. `newdata` (`NULL` or `data.frame(n.new, p)`) This argument can be used, when the `SVC_mle` function has been called with an formula, see examples. `compute.y.var` (`logical(1)`) If `TRUE` and the response is being estimated, the predictive variance of each estimate will be computed. `...` further arguments

Value

The function returns a data frame of `n.new` rows and with columns

• `SVC_1, ..., SVC_p`: the predicted SVC at locations `newlocs`.

• `y.pred`, if `newX` and `newW` are provided

• `y.var`, if `newX` and `newW` are provided and `compute.y.var` is set to `TRUE`.

• `loc_x, loc_y`, the locations of the predictions

Jakob Dambon

References

Dambon, J. A., Sigrist, F., Furrer, R. (2021) Maximum likelihood estimation of spatially varying coefficient models for large data with an application to real estate price prediction, Spatial Statistics doi: 10.1016/j.spasta.2020.100470

`SVC_mle`

Examples

```## ---- toy example ----
## We use the sampled, i.e., one dimensional SVCs
str(SVCdata)
# sub-sample data to have feasible run time for example
set.seed(123)
id <- sample(length(SVCdata\$locs), 50)

## SVC_mle call with matrix arguments
fit_mat <- with(SVCdata, SVC_mle(
y[id], X[id, ], locs[id],
control = SVC_mle_control(profileLik = TRUE, cov.name = "mat32")))

## SVC_mle call with formula
df <- with(SVCdata, data.frame(y = y[id], X = X[id, -1]))
fit_form <- SVC_mle(
y ~ X, data = df, locs = SVCdata\$locs[id],
control = SVC_mle_control(profileLik = TRUE, cov.name = "mat32")
)

## prediction

# predicting SVCs
predict(fit_mat, newlocs = 1:2)
predict(fit_form, newlocs = 1:2)

# predicting SVCs and response providing new covariates
predict(
fit_mat,
newX = matrix(c(1, 1, 3, 4), ncol = 2),
newW = matrix(c(1, 1, 3, 4), ncol = 2),
newlocs = 1:2
)
predict(fit_form, newdata = data.frame(X = 3:4), newlocs = 1:2)

```

varycoef documentation built on Sept. 18, 2022, 1:07 a.m.