zhangtao 发表于 2012-11-8 15:10
epoh老师,您好!
现在的问题是无法读入uexample and sexample这两个数据,
我命令都对,怎么会读不进去 ...
library(splm)
data(Produc, package = "Ecdat")
data(usaww)
write.csv(Produc,"Sexample.csv",row.names = FALSE,col.names = TRUE)
write.csv(usaww,"Uexample.csv",row.names = FALSE,col.names = TRUE)
Sexample=read.csv("Sexample.csv")
Uexample=read.csv("Uexample.csv")
Uexample=data.matrix(Uexample)
fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
## the two standard specifications (SEM and SAR) one with FE
## and the other with RE:
## fixed effects panel with spatial errors
fespaterr <- spml(fm, data = Sexample, listw = mat2listw(Uexample), model="within", spatial.error="b")
summary(fespaterr)
########
Spatial panel fixed effects error model
Call:
spml(formula = fm, data = Sexample, listw = mat2listw(Uexample),
model = "within", spatial.error = "b")
Residuals:
Min. 1st Qu. Median 3rd Qu. Max.
-0.1250 -0.0238 -0.0035 0.0171 0.1880
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
rho 0.5574013 0.0330749 16.8527 < 2e-16 ***
log(pcap) 0.0051438 0.0250109 0.2057 0.83705
log(pc) 0.2053026 0.0231427 8.8712 < 2e-16 ***
log(emp) 0.7822540 0.0278057 28.1328 < 2e-16 ***
unemp -0.0022317 0.0010709 -2.0839 0.03717 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#########
## random effects panel with spatial lag
respatlag <- spml(fm, data = Sexample, listw = mat2listw(Uexample), model="random", spatial.error="none", lag=TRUE)
summary(respatlag)
########
Spatial panel random effects ML model
Call:
spml(formula = fm, data = Sexample, listw = mat2listw(Uexample),
model = "random", lag = TRUE, spatial.error = "none")
Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.38 1.57 1.70 1.70 1.80 2.13
Error variance parameters:
Estimate Std. Error t-value Pr(>|t|)
phi 21.3175 8.2937 2.5703 0.01016 *
Spatial autoregressive coefficient:
Estimate Std. Error t-value Pr(>|t|)
lambda 0.161615 0.029041 5.5651 2.62e-08 ***
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
(Intercept) 1.65814995 0.15071855 11.0016 < 2.2e-16 ***
log(pcap) 0.01294505 0.02493997 0.5190 0.6037
log(pc) 0.22555376 0.02163422 10.4258 < 2.2e-16 ***
log(emp) 0.67081075 0.02642113 25.3892 < 2.2e-16 ***
unemp -0.00579716 0.00089175 -6.5009 7.984e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1