predict: Prediction methods for the 'spflow_model-class()'

predict_effectR Documentation

Prediction methods for the spflow_model-class()

Description

The methods predict() and predict_effect() compute spatial predictions. The former will return the predicted values of the dependent variables and the later computes the change in its levels given the input data changes.

Usage

predict_effect(object, ...)

## S4 method for signature 'spflow_model'
predict(
  object,
  new_dat = NULL,
  method = "BPA",
  approx_expectation = TRUE,
  expectation_approx_order = 10,
  return_type = "OD",
  add_new_signal = FALSE
)

## S4 method for signature 'spflow_model'
predict_effect(
  object,
  new_dat,
  old_signal = NULL,
  approx_expectation = TRUE,
  expectation_approx_order = 10,
  return_type = "OD",
  y_is_log = FALSE
)

Arguments

object

A spflow_model-class()

...

not used (generic).

new_dat

A named list of data.frames that contain the new data. The names should correspond to spflow_network or spflow_pair objects contained in the spflow_network_multi-class().

method

A character indicating which method to use for computing the predictions. Should be one of c("TS", "TC", "BP").

approx_expectation

A logical, if TRUE the expected value of the dependent variable is approximated by a Taylor series. For spatial models this can lead to significant performance gains.

expectation_approx_order

A numeric, defining the order of the Taylor series approximation.

return_type

A character indicating the format of the returned values:

  • "V" leads to an atomic vector

  • "M" leads to a OD matrix where missing data is replaced by zeros

  • "OD" leads to a data.frame with columns being the the values and the id's of the destinations and the origins

add_new_signal

A logical, if TRUE the new signal is added to the as a column to the results. This only works when the return type is "OD".

old_signal

A matrix that can be supplied to specify the reference value for the signal. If not given the signal contained in the model is used.

y_is_log

Logical, if TRUE the dependent variable is considered to be in logarithms and the effects calculation is adjusted by the method proposed by Laurent et. al. (2023).

Details

The prediction methods used here have been developed or analyzed by \insertCiteGoulard2017;textualspflow. \insertCiteDargel2023;textualspflow describe how they can be adapted to the case of interaction models.

Value

Predicted values in the format specified by the argument return_type.

References

\insertAllCited

-Laurent, Thibault, Paula Margaretic, and Christine Thomas‐Agnan. "Generalizing impact computations for the autoregressive spatial interaction model." Geographical Analysis (2023).


LukeCe/spflow documentation built on Nov. 11, 2023, 8:20 p.m.