




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、空间面板数据分析 R的 splm包(任建辉,暨南大学)The splm package provides methods for fitting spatial panel data by maximum likelihood and GM.安装 R 软件及其编辑器 Rstudio网址: 下载好 Rstudio 以后,操作都可以 Rstudio 中完成了,包括命令的编写、命令运行、图形 展示,最方便的要数查看数据了。R 界面 Rstudio 界面,形如 matlab 下面进入正题, 了解 splm 包中的数据、 命令及结果展示。 所有命令都写在编辑窗口 ( s
2、tudio 左上区域),可以单独的运行每行命令,也可选取一段一起执行,点 run 按钮。1、首先,安装 splm 包并导入,命令如下 :intall.packages( “splm ”),选择最近的下载点 library(splm) library(splm) 载入需要的程辑包: MASS 载入需要的程辑包: nlme 载入需要的程辑包: spdep 载入需要的程辑包: sp 载入需要的程辑包: Matrix 载入需要的程辑包: plm 载入需要的程辑包: bdsmatrix 载入程辑包: bdsmatrix 下列对象被屏蔽了 from package:base :backsolve 载入需要
3、的程辑包: Formula 载入需要的程辑包: sandwich 载入需要的程辑包: zoo 载入程辑包: zoo 下列对象被屏蔽了 from package:base : 载入需要的程辑包: spam 载入需要的程辑包: gridSpam version 0.40-0 (2013-09-11) is loaded.Type help( Spam) or demo( spam) for a short introduction and overview of this package.Help for individual functions is also obtained by addin
4、g the suffix .spam to the function name, e.g. help( chol.spam). 载入程辑包: spam 下列对象被屏蔽了 from package:bdsmatrix :backsolve 下列对象被屏蔽了 from package:base :backsolve, forwardsolve载入需要的程辑包:ibdreg载入需要的程辑包:car载入需要的程辑包:lmtest载入需要的程辑包:Ecdat载入程辑包: Ecdat下列对象被屏蔽了from package:car :Mroz下列对象被屏蔽了from package:nlme :Gasol
5、ine下列对象被屏蔽了from package:MASS:SP500下列对象被屏蔽了from package:datasets :Orange载入需要的程辑包:maxLik载入需要的程辑包: miscToolsPlease cite the maxLik package as:Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelih ood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s001 80-
6、010-0217-1.If you have questions, suggestions, or comments regarding the maxLik package, please use a forum or tracker at maxLiks R-Forge site:Warning message: 程辑包 Matrix 是用 R 版本 3.0.3 来建造的 注意:在导入 splm 时,如果发现还有其他配套的包没有安装,需要先安装。2、接着,查看数据及结构,命令如下: data(Produc,package=”Ecdat”) View(Produc)3、引入空间权重矩阵( s
7、patial weights matrix ),命令如下 data(usaww)Views(usaww)4、空间面板数据的广义矩估计,命令spgmGM GM summary(GM)Spatial panel fixed effects GM modelCall: spgm(formula = log(gsp) log(pcap) + log(pc) + log(emp) + unemp,data = Produc, listw = usaww, spatial.error = TRUE, moments = fullweights )Residuals:Min. 1st Qu. Median
8、3rd Qu. Max.0.1 1”within ”,0.1 1”random”,-0.14000 -0.01950 -0.00316 0.01530 0.16800Estimated spatial coefficient, variance components and theta:Estimaterho 0.3277625 sigma2_v 0.0012179Coefficients:Estimate Std. Error t-value Pr(|t|)log(pcap) -0.0022435 0.0262646 -0.0854 0.9319295 log(pc) 0.2414979 0
9、.0235826 10.2405 2.2e-16 * log(emp) 0.7813276 0.0283855 27.5256 2.2e-16 * unemp -0.0036026 0.0010094 -3.5691 0.0003582 *Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 5、空间面板极大似然估计,命令spmlfm- log(gsp)log(pcap)+log(pc)+log(emp)+unemp# fixed effects panel with spatial errorsFespaterr fm Fespaterr summary(Fesp
10、aterr)Spatial panel fixed effects error model Call: spml(formula = fm, data = Produc, listw = mat2listw(usaww), model = within,spatial.error = b, hess = FALSE) Residuals:Min. 1st Qu. Median 3rd Qu. Max.-0.1250 -0.0238 -0.0035 0.0171 0.1880Coefficients:Estimate Std. Error t-value Pr(|t|)0.5574013 0.0
11、329554 16.9138 2e-16 * log(pcap) 0.0051438 0.0250724 0.2052 0.83745 log(pc) 0.2053026 0.0231996 8.8494 2e-16 * log(emp) 0.7822540 0.0278741 28.0638 2e-16 *-0.0022317 0.0010735 -2.0788 0.03764 *Signif. codes: 0 * 0.001 * 0.01 * 0.05 . #random effects panal with spatial lag Respatlag Respatlag summary
12、(Respatlag)Spatial panel random effects ML modelCall: spreml(formula = formula, data = data, index = index, w = listw2mat(listw),w2 = listw2mat(listw2), lag = lag, errors = errors, cl = cl)Residuals:Min. 1st Qu. Median Mean 3rd Qu. Max.1.38 1.57 1.70 1.70 1.80 2.13Error variance parameters:Estimate
13、Std. Error t-value Pr(|t|) phi 21.3175 8.3017 2.5678 0.01023 *Spatial autoregressive coefficient:Estimate Std. Error t-value Pr(|t|) lambda 0.161615 0.029099 5.554 2.793e-08 *Coefficients:Estimate Std. Error t-value Pr(|t|) log(pcap) 0.01294505 0.02493997 0.5190 0.6037 unemp -0.00579716 0.00089175 -
14、6.5009 7.984e-11 *Signif. codes: 0* 0.001 * 0.01 * 0.05 . 0.1 16、伴有随机效应和序列误差相关的空间面板模型的极大似然估计,命令speml#random effects panel with spatial lag and serial error correlation #optimization method set to “BFGS“ Sarsrmod Sarsrmod summary(Sarsrmod) Spatial panel random effects ML modelCall:spreml(formula = fm
15、, data = Produc, w = usaww, lag = TRUE, errors = sr, method = BFGS)Residuals:Min. 1st Qu. Median Mean 3rd Qu. Max.2.66 3.02 3.18 3.18 3.31 3.77Error variance parameters:Estimate Std. Error t-value Pr(|t|)Spatial autoregressive coefficient:Estimate Std. Error t-value Pr(|t|) lambda 0.302942 0.030376
16、9.973 |t|) log(pcap) 0.08257977 0.03617371 2.2829 0.02244 * log(pc) 0.01509919 0.01977324 0.7636 0.44510unemp -0.00270962 0.00065851 -4.1148 3.875e-05 *Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 17、模型检验(1)bsjktest , Baltigi,Song,Jung, and Koh LM test for spatial panels bsjktest(fm, data=Produc, li
17、stw = usaww, test=C.1)Baltagi, Song, Jung and Koh C.1 conditional test data: log(gsp) log(pcap) + log(pc) + log(emp) + unemp LM = 0.2617, df = 1, p-value = 0.609 alternative hypothesis: spatial dependence in error terms, sub RE and serial c orr.(2)bsktest, Baltigi,Song and Koh LM test for spatial pa
18、nels bsktest(fm,data=Produc, listw = mat2listw(usaww),+test=LM1, standardize=TRUE)Baltagi, Song and Koh SLM1 marginal test data: log(gsp) log(pcap) + log(pc) + log(emp) + unemp SLM1 = 0.083, p-value = 0.9338 alternative hypothesis: Random effects(3)Covariance extractor method for splm objects sarrem
19、od library(lmtest) coeftest(sarremod) z test of coefficients:Estimate Std. Error z value Pr(|z|) log(pcap) 0.01294505 0.02493997 0.5190 0.6037 unemp -0.00579716 0.00089175 -6.5009 7.984e-11 *Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 library(car) lht(sarremod,log(pcap)=log(pc) Linear hypothesis
20、test Hypothesis:log(pcap) - log(pc) = 0 Model 1: restricted model Model 2: function (x, .) UseMethod(formula)Df Chisq Pr(Chisq) 12 1 36.268 1.719e-09 *Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1(更多详情请查看 splm 的 help 文档以及文后列的参考文献 )参考文献1.Baltagi,B.H.,Song,S.H.,Jung B. and Koh, W.(2007) Testing panel
21、 data regression models with spatial and serial error correlation. Journal of Econometrics,140,5-512.Baltagi,B.H.,Song,S.H and Koh, W.(2003) Testing panel data regression models with spatial error correlation. Journal of Econometrics,117,123-1503.Millo,G.,Piras,G.(2012) splm:Spatial Panel Data Model
22、s in R. Journal of Statistical Software,47(1),1-38.URL4.Elhorst, J.P (2003) Specification and estimation of spatial panel data models, International Regional Science Review,26,pages 244-2685.Elhorst, J.P(2009) Spatial panel data models, In Fisher,M.M. and Getis,A.(eds),Handbook of Applied Spatial An
23、alysis Springer,Berlin6.Giovanni Millo and Gaetano Carmeci,(2011) “Non-life insurance consumption in Italy: a subregional panel data analysis ”, Journal of Geographical Systems,13:273-2987.Qu Feng and William C. Horrace,(2012) ”Alternative Measures of Technical Efficiency :Skew,Bias and Scale ”, Journal of Applied Econometrics, Forthcoming.8.Kapoor,M.,Kelejian,H.H. and Prucha,I.R.(2007) Panel data model with spatially correlated error components,Journal of Econometrics,140,pages 97-1309.Mutl,J.,and
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 学生自救互救知识培训课件
- 学生用电教育知识培训内容课件
- 学前安全防范知识培训课件
- 2025版网红直播带货合作协议
- 二零二五年昆山酒店物业费收取与酒店管理服务合同
- 二零二五年度房地产沙盘模型制作与市场推广服务合同
- 二零二五年度餐饮连锁企业一次性餐具集中采购合同
- 二零二五年度拆迁工程前期手续办理居间服务合同
- 二零二五年度绿色建材瓷砖采购与安装服务合同
- 二零二五年度房地产项目预售合同范本
- 动力电池气密性检测及故障处理
- 2025年文化产业与商业模式知识测评试卷及答案
- 中建材特种玻璃深加工一期工程项目环评报告
- T/GIEHA 013-2019商用厨房油烟管道系统清洗规范
- 团体标准解读及临床应用-成人经鼻高流量湿化氧疗技术规范2025
- 旧房拆除重建协议书
- 2025质量工程师笔试题库及答案
- 期货保密协议书
- 船舶运输公司水上船舶运输安全应急预案
- 2025安全生产法律法规专题知识培训
- 代建管理工作程序
评论
0/150
提交评论