library(splm)
library(plm)
data(Produc)
data(usaww)
########SPATIAL LAG MODEL######
#no space no endog: error use plm
if (FALSE) GM_lag_b2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = FALSE, method = "b2sls",
listw = usaww)
#no space but endog
GM_b2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap),
method = "b2sls",
instruments = ~log(hwy), listw = usaww)
summary(GM_b2sls_e)
GM_g2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap),
method = "g2sls",
instruments = ~log(hwy), listw = usaww)
summary(GM_g2sls_e)
GM_ec2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap),
method = "ec2sls",
instruments = ~log(hwy), listw = usaww)
summary(GM_ec2sls_e)
GM_w2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = FALSE, endog = ~ log(pcap),
method = "w2sls",
instruments = ~log(hwy), listw = usaww)
summary(GM_w2sls_e)
#SPATIAL LAG MODEL
GM_lag_b2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = TRUE, spatial.error = FALSE, method = "b2sls",
listw = usaww)
summary(GM_lag_b2sls)
GM_lag_g2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = TRUE, spatial.error = FALSE, method = "g2sls",
listw = usaww)
summary(GM_lag_g2sls)
GM_lag_ec2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = TRUE, spatial.error = FALSE, method = "ec2sls",
listw = usaww)
summary(GM_lag_ec2sls)
GM_lag_w2sls <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = TRUE, spatial.error = FALSE,
listw = usaww, method = "w2sls")
summary(GM_lag_w2sls)
#endogenous
GM_lag_b2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = TRUE,
spatial.error = FALSE, endog = ~ log(pcap),
method = "b2sls",
instruments = ~log(hwy), listw = usaww)
summary(GM_lag_b2sls_e)
GM_lag_g2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = TRUE,
spatial.error = FALSE, endog = ~ log(pcap),
method = "g2sls",
instruments = ~log(hwy), listw = usaww)
summary(GM_lag_g2sls_e)
GM_lag_ec2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = TRUE,
spatial.error = FALSE, endog = ~ log(pcap),
method = "ec2sls",
instruments = ~log(hwy), listw = usaww)
summary(GM_lag_ec2sls_e)
GM_lag_w2sls_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = TRUE,
spatial.error = FALSE, endog = ~ log(pcap),
method = "w2sls",
instruments = ~log(hwy), listw = usaww)
summary(GM_lag_w2sls_e)
########SPATIAL ERROR MODEL######
GM_error_within <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = TRUE, model = "within",
listw = usaww)
summary(GM_error_within)
GM_error_random <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = TRUE, model = "random",
listw = usaww)
summary(GM_error_random)
GM_error_within_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = TRUE, model = "within",
listw = usaww, moments = "fullweights")
summary(GM_error_within_fw)
GM_error_random_w <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = FALSE, spatial.error = TRUE, model = "random",
listw = usaww, moments = "fullweights")
summary(GM_error_random_w)
#endogenous
GM_error_within_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = FALSE,
spatial.error = TRUE, endog = ~ log(pcap),
model = "within",
instruments = ~log(hwy), listw = usaww)
summary(GM_error_within_e)
GM_error_random_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = FALSE,
spatial.error = TRUE, endog = ~ log(pcap),
model = "random",
instruments = ~log(hwy), listw = usaww)
summary(GM_error_random_e)
########SARAR MODEL######
GM_sarar_within <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = TRUE, spatial.error = TRUE, model = "within",
listw = usaww)
summary(GM_sarar_within)
GM_sarar_random <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = TRUE, spatial.error = TRUE, model = "random",
listw = usaww)
summary(GM_sarar_random)
GM_sarar_within_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = TRUE, spatial.error = TRUE, model = "within",
listw = usaww, moments = "fullweights")
summary(GM_sarar_within_fw)
GM_sarar_random_fw <- spgm(log(gsp) ~ log(pcap) + log(pc) + unemp, data=Produc,
lag = TRUE, spatial.error = TRUE, model = "random",
listw = usaww, moments = "fullweights")
summary(GM_sarar_random_fw)
#endogenous
GM_sarar_within_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = TRUE,
spatial.error = TRUE, endog = ~ log(pcap),
model = "within",
instruments = ~log(hwy), listw = usaww)
summary(GM_sarar_within_e)
GM_sarar_random_e <- spgm(log(gsp) ~ log(pc) + unemp, data=Produc,
lag = TRUE,
spatial.error = TRUE, endog = ~ log(pcap),
model = "random",
instruments = ~log(hwy), listw = usaww)
summary(GM_sarar_random_e)
Run the code above in your browser using DataLab