derive_spflow_matrices: Compute the design matrices used during the estimation with...

View source: R/spflow_matrices.R

derive_spflow_matricesR Documentation

Compute the design matrices used during the estimation with spflow()

Description

These are internal functions called within the estimation procedure

Usage

derive_spflow_matrices(
  id_net_pair,
  spflow_networks,
  spflow_formula,
  spflow_control,
  na_rm = FALSE
)

Details

The key to an efficient estimation is to preserve the relational representation of the data for origins, destinations and origins-destinations pairs. This requires to be aware of the following;

  • there are up to three sources of data: OD-pairs & origin-nodes & destination-nodes

  • each variable may be used in three different ways: directly & as a spatial lag (like in the SDM) & as an instrument for the S2SLS estimator

  • the model matrices can be split into five groups

    1. "Y_" = OD-flows (the dependent variable, in matrix form)

    2. "P_" = OD-pair attributes (in matrix form)

    3. "D_" = destination attributes

    4. "O_" = origin attributes

    5. "I_" = intra-regional attributes

The additional separation of model matrices and data-sources makes sense if the list of origins coincides with the list of destinations. In this case, we can use data from the same set of nodes as origin, destination, and intra-regional characteristics and each of these enter the model in different ways.

The model formula interface in spflow() is used to specify, how the variables in the data-sources are used. Any transformations of variables are handled by R's build-in tools and spatial lags, that are specified in the augments sdm_variables and twosls_instrumental_variables to spflow_control() are calculated after transformations have been applied. Below is an explanation of the formula parts:

  • "norm" variables are not lagged

  • "sdm" variables are lagged once and used as explanatory variables

  • "inst" variables are lagged twice and used as instruments. If a variable is at the same time as instrument and as sdm-variable we have to increase the lags-order to avoid multicollinearity issues \insertCiteDargel2021spflow.

Value

A list containing all design matrices required for estimation, impact calculation and prediction

References

\insertAllCited

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