Predict using a fitted SPM model on the whole data or on new data

# S4 method for sspm_fit
predict(
object,
new_data = NULL,
biomass = NULL,
aggregate = FALSE,
interval = FALSE,
next_ts = FALSE,
type = "response"
)

# S4 method for sspm_dataset
predict(
object,
new_data = NULL,
discrete = TRUE,
type = "response",
interval = FALSE
)

## Arguments

object

[sspm_fit] Fit object to predict from.

new_data

[data.frame] New data to predict with.

biomass

[character] Biomass variable.

aggregate

[logical] For biomass predictions only, whether to aggregate the data to the boundary level. Default to FALSE.

interval

[logical] Whether or not to calculate confidence, and when possible, prediction intervals.

next_ts

[logical] For biomass, predict next timestep.

type

When this has the value "link" (default) the linear predictor (possibly with associated standard errors) is returned. When type="terms" each component of the linear predictor is returned seperately (possibly with standard errors): this includes parametric model components, followed by each smooth component, but excludes any offset and any intercept. type="iterms" is the same, except that any standard errors returned for smooth components will include the uncertainty about the intercept/overall mean. When type="response" predictions on the scale of the response are returned (possibly with approximate standard errors). When type="lpmatrix" then a matrix is returned which yields the values of the linear predictor (minus any offset) when postmultiplied by the parameter vector (in this case se.fit is ignored). The latter option is most useful for getting variance estimates for quantities derived from the model: for example integrated quantities, or derivatives of smooths. A linear predictor matrix can also be used to implement approximate prediction outside R (see example code, below).

discrete

[logical] If new_data is NULL, whether to predict based on a discrete prediction matrix (default to TRUE).

## Value

A dataframe of predictions.

## Examples

if (FALSE) {
# Predictions for a model fit (usually, productivity)
predict(sspm_model_fit)
# To get biomass predictions, provide the variable name
predict(sspm_model_fit, biomass = "weight_per_km2_borealis")
# To get the next timestep predictions
predict(sspm_model_fit, biomass = "weight_per_km2_borealis", next_ts = TRUE)
}