The method computes person correlations for all variables available for the the origins, destinations, and OD-pairs. The OD-pairs information can be either come from a spflow_network_multi or a spflow_models.

pair_cor(object, ...)

# S4 method for spflow_network_multi
pair_cor(
  object,
  id_net_pair = id(object)[["pairs"]][[1]],
  spflow_formula,
  add_lags_x = TRUE,
  add_lags_y = FALSE
)

# S4 method for spflow_model
pair_cor(
  object,
  add_fitted = TRUE,
  add_resid = TRUE,
  model,
  exploit_fit = TRUE
)

Arguments

object

A spflow_model-class() or a spflow_network_multi-class()

...

Arguments to be passed to methods

id_net_pair

A character indicating the id of a spflow_network_pair-class()

spflow_formula

A formula specifying how variables should be used (for details see section Formula interface in the help page of spflow())

add_lags_x

A logical, indicating whether spatial lags of the exogenous variables should be included.

add_lags_y

A logical, indicating whether spatial lags of the dependent variables should be included.

add_resid, add_fitted

Logicals, indicating whether the model residuals and fitted value should be added to the correlation matrix

model

A character indicating the model number, that controls different spatial dependence structures should be one of paste0("model_", 1:9). Details are given in the documentation of spflow_control().

exploit_fit

A logical, if TRUE the correlation that is generated as a byproduct of fitting the model is returned. Otherwise it is recreated from the input data, without considering the weights.

Value

A matrix of pairwise correlations between all variables

Author

Lukas Dargel

Examples


# Used with a spflow_network_multi ...
cor_mat <- pair_cor(multi_net_usa_ge, "ge_ge") # without transformations
cor_image(cor_mat)


cor_mat <- pair_cor( # with transformations and spatial lags
  multi_net_usa_ge,
  "ge_ge",
  y9 ~ . + P_(log(DISTANCE + 1) + .),
  add_lags_y = TRUE)
cor_image(cor_mat)


# Used with a model...
gravity_ge <- spflow(
  y1 ~ . + P_(DISTANCE),
  multi_net_usa_ge,
  "ge_ge",
  spflow_control(model = "model_1"))

cor_mat <- pair_cor(gravity_ge)
cor_image(cor_mat)