#### Example 1: Spatial Phillips-Curve. Anselin (1988, p. 203)
rm(list = ls()) # Clean memory
data(spc)
lwspc <- spdep::mat2listw(Wspc, style = "W")
## No endogenous regressors
Tformula <- WAGE83 | WAGE81 ~ UN83 + NMR83 + SMSA | UN80 + NMR80 + SMSA
## Endogenous regressors and Instruments
Tformula2 <- WAGE83 | WAGE81 ~ NMR83 | NMR80
## Endogenous regressors: UN83 , UN80
## Instrumental variable: SMSA
## A IV model with endogenous regressors only in first equation
spciv <- spsurgs3sls(formula = Tformula2, data = spc,
type = "iv", listw = lwspc,
endog = ~ UN83 | .,
instruments = ~ SMSA | .)
summary(spciv)
print(spciv)
#########################################################################
## A SLM model with endogenous regressors
spcslm <- spsurgs3sls(formula = Tformula2, data = spc,
endog = ~ UN83 | .,
instruments = ~ SMSA |.,
type = "slm",
listw = lwspc)
summary(spcslm)
print(spcslm)
impacts_spcslm <- impactspsur(spcslm, listw = lwspc, R = 1000)
summary(impacts_spcslm[[1]], zstats = TRUE, short = TRUE)
summary(impacts_spcslm[[2]], zstats = TRUE, short = TRUE)
#########################################################################
## A SDM model with endogenous regressors
spcsdm <- spsurgs3sls(formula = Tformula2, data = spc,
endog = ~ UN83 | UN80,
instruments = ~ SMSA | SMSA,
type = "sdm", listw = lwspc,
Durbin = ~ NMR83 | NMR80)
summary(spcsdm)
## Durbin only in one equation
spcsdm2 <- spsurgs3sls(formula = Tformula2, data = spc,
endog = ~ UN83 | UN80,
instruments = ~ SMSA | SMSA,
type = "sdm", listw = lwspc,
Durbin = ~ NMR83 | .)
summary(spcsdm2)
#########################################################################
## A SEM model with endogenous regressors
spcsem <- spsurgs3sls(formula = Tformula2, data = spc,
endog = ~ UN83 | UN80,
instruments = ~ SMSA | SMSA,
type = "sem", listw = lwspc)
summary(spcsem)
print(spcsem)
#########################################################################
## A SARAR model with endogenous regressors
spcsarar <- spsurgs3sls(formula = Tformula2, data = spc,
endog = ~ UN83 | UN80,
instruments = ~ SMSA | SMSA,
type = "sarar", listw = lwspc)
summary(spcsarar)
print(spcsarar)
impacts_spcsarar <- impactspsur(spcsarar, listw = lwspc, R = 1000)
summary(impacts_spcsarar[[1]], zstats = TRUE, short = TRUE)
summary(impacts_spcsarar[[2]], zstats = TRUE, short = TRUE)
Run the code above in your browser using DataLab