Marginal effect in spatial econometric models are observation dependent. Here we compute the changes to all observations that follow from changes in a one variable for one (or multiple) observations. Here, these effects are represented as a matrix with the same dimension as the dependent variable.

# S4 method for spflow_model
impacts_matrix(
  object,
  ...,
  change_net,
  change_var,
  change_obs = 1L,
  x_is_log = FALSE
)

Arguments

object

an spflow_model-class()

...

arguments passed on to predict_effect()

change_net

a character of length one, identifying one of the spflow_network_classes() where changes to the data should be applied

change_var

a character of length one, identifying one variable The character musts refer to the variable and its name to the id of

change_obs

A numeric that identifies the observation(s) to change (by position)

x_is_log

A logical, if TRUE the independent variable is assumed to be in logs and the effects are computed for a relative change of the form x_new = 1.01 * x_old. If FALSE the effects are computed for a unit increase of the form x_new = 1 + x_old.

Value

A Matrix

See also

predict_effect

Author

Lukas Dargel

Examples


model9 <- spflow(
spflow_formula = y9 ~ . + P_(DISTANCE),
spflow_networks = multi_net_usa_ge,
id_net_pair = "ge_ge")

# effect matrix, summary and decomposition
MI <- impacts_matrix(model9,change_net = "ge",change_var =  "X", change_obs = 8)
total_effect <- sum(MI)
intra_effect <- MI[8,8]
origi_effect <- sum(MI[,8]) - intra_effect
desti_effect <- sum(MI[8,]) - intra_effect
netwo_effect <- sum(MI[-8,-8])
total_effect == (intra_effect + origi_effect + desti_effect + netwo_effect)
#>    RP 
#> FALSE