strv_predict: Use a fitted model to predict.

strv_predictR Documentation

Use a fitted model to predict.

Description

Use a fitted model to predict.

Usage

strv_predict(x, new_data, ...)

## S4 method for signature 'starve,sf'
strv_predict(x, new_data)

## S4 method for signature 'starve,RasterLayer'
strv_predict(x, new_data, covariates, time = "model")

Arguments

x

A fitted model

new_data

The new set of data for which to predict

...

Extra options

covariates

A list of Raster* objects for raster predictions. If the model has no covariates, then nothing needs to be supplied.

If new_data is of class RasterLayer, then covariates should be a list of Raster* objects. Each Raster* object shouldcontain data for one covariate, should have one layer for each time unit, and should have the same raster geometry as the new_data object. The layer names of each raster layer should be of the form T####, where #### gives the specific time index. The geometry of all the Raster* objects should be identical.

time

Integer vector. At what time indices should predictions be made? For the default value "model", predictions are made for every time present in the model data.

Value

Predictions for the new data

Methods (by class)

  • strv_predict(x = starve, new_data = sf): Predict/forecast at the specific locations and times given in new_data. Any covariates used to fit the model should be included in the rows of new_data. Returns a long_stars object containing a copy of new_data and the associated predictions and standard errors for the random effects and response mean on both the link and natural scale.

  • strv_predict(x = starve, new_data = RasterLayer): Predictions will be made for all raster cells whose value are not NA. If the raster has no values, then predictions will be made at every raster cell. Raster predictions are not treated as areal data, instead point predictions are made at the midpoint of each raster cell. The value of the midpoint prediction is taken as the prediction for that cell. Returns a stars object whose first two dimensions are the raster geometry of new_data, the third dimension is the time index given in time, and the fourth dimension is the response variable.

Random effect predictions

Predictions of spatio-temporal random effects.

If there are prediction times that are outside the range of times of the model, then persistent graph random effects are added to the model to cover these additional times. Then a prediction graph is created which describes which random effect locations (including both persistent graph and transient graph locations) are used as nearest neighbours when finding the predictive distribution for the spatio-temporal random effect at each prediction location.

We then add the predictive distributions for the prediction random effects to the model likelihood function. The predicted values and standard errors for the random effect are found by optimizing the augmented likelihood function evaluated at the model parameter values. Note that the standard errors for the predicted random effects take into account uncertainty in the model parameter estimates.

Linear predictions

Predictions of response mean before applying the link function.

The predicted value for the linear predictor is given by X*beta + w where X is the covariate value for the prediction location, beta is the vector of model regression coefficients, and w is the predicted random effect value for the prediction location.

The standard error for the prediction is given by sqrt(X*SE*X^T + w_se^2) where SE is the parameter estimate covariance matrix for the regression coefficients and w_se is the standard errors for the random effect prediction. Note that these standard errors assume that the estimators for the regression coeffiecients are independent from the random effects, which may not be true if the covariates are spatially structured due to an effect called spatial confounding.

Response predictions

Predictions of response mean after applying the link function.

The predicted value for the response mean is the linear predictor transformed to the scale of data by applying the link function. The standard error for the prediction is obtained via the delta method using a second-order Taylor approximation.


lawlerem/staRVe documentation built on Oct. 9, 2024, 4:48 a.m.