贝叶斯空间计量模型Word文件下载.docx
《贝叶斯空间计量模型Word文件下载.docx》由会员分享,可在线阅读,更多相关《贝叶斯空间计量模型Word文件下载.docx(7页珍藏版)》请在冰豆网上搜索。
采用MCMC(MarkovChainMonteCarlo)参数估计思想,具体的抽样方法选择吉布斯抽样方法(Gibbssamplingapproach)
在随意给定待估参数一个初始值之后,开始生成参数的新数值,并根据新数值生成其他参数的新数值,如此往复,对每一个待估参数,将得到一组生成的数值,根据该组数值,计算其均值,即为待估参数的贝叶斯估计值。
三、贝叶斯空间计量模型的类型
空间自回归模型far_g()
空间滞后模型(空间回归自回归混合模型)sar_g()
空间误差模型sem_g()
广义空间模型(空间自相关模型)sac_g()
四、贝叶斯空间模型与普通空间模型的选择标准
首先按照参数显著性,以及极大似然值,确定普通空间计量模型的具体类型,之后对于该确定的类型,再判断是否需要进一步采用贝叶斯估计方法。
标准一:
对普通空间计量模型的残差项做图,观察参数项是否是正态分布,若非正态分布,则考虑使用贝叶斯方法估计。
技巧:
r=30的贝叶斯估计等价于普通空间计量模型估计,此时可以做出v的分布图,观察其是否基本等于1,若否,则应采用贝叶斯估计方法。
标准二:
若按标准一发现存在异方差,采用贝叶斯估计后,如果参数结果与普通空间计量方法存在较大差异,则说明采用贝叶斯估计是必要的。
例1:
选举投票率普通SAR与贝叶斯SAR对比:
loadelect.dat;
loadford.dat;
y=elect(:
7)./elect(:
8);
x1=elect(:
9)./elect(:
x2=elect(:
10)./elect(:
x3=elect(:
11)./elect(:
w=sparse(ford(:
1),ford(:
2),ford(:
3));
x=[ones(3107,1)x1x2x3];
res1=sar(y,x,w);
res2=sar_g(y,x,w,2100,100);
Vnames=strvcat(‘voter’,’const’,‘educ’,‘home’,‘income’);
prt(res1);
prt(res2);
SpatialautoregressiveModelEstimates
DependentVariable=voter
R-squared=0.4605
Rbar-squared=0.4600
sigma^2=0.0041
Nobs,Nvars=3107,4
log-likelihood=5091.6196
#ofiterations=11
minandmaxrho=-1.0000,1.0000
totaltimeinsecs=1.0530
timeforlndet=0.2330
timefort-stats=0.0220
timeforx-impacts=0.7380
#drawsx-impacts=1000
PaceandBarry,1999MClndetapproximationused
orderforMCappr=50
iterforMCappr=30
VariableCoefficientAsymptott-statz-probability
const-0.100304-8.4062990.000000
educ0.33570421.9010990.000000
home0.75406028.2122110.000000
income-0.008135-8.5352120.000000
rho0.527962335.7243590.000000
检验是否存在异方差---------是否存在遗漏变量:
贝叶斯----------对列向量做柱状图。
bar(res.vmean);
Bayesianspatialautoregressivemodel
Heteroscedasticmodel
R-squared=0.4425
Rbar-squared=0.4419
meanofsigedraws=0.0023
sige,epe/(n-k)=0.0065
r-value=4
ndraws,nomit=2100,100
totaltimeinsecs=20.6420
timeforlndet=0.2370
timeforsampling=19.2790
PosteriorEstimates
VariableCoefficientStdDeviationp-level
const-0.1078630.0127290.000000
educ0.3484160.0180720.000000
home0.7277990.0264160.000000
income-0.0096030.0010500.000000
rho0.5610540.0133130.000000
对遗漏变量的测量:
lat=elect(:
5);
lon=elect(:
6);
[lonsli]=sort(lon);
lats=lat(li,1);
elects=elect(li,:
);
y=elects(:
7)./elects(:
x1=elects(:
9)./elects(:
x2=elecrs(:
10)./elects(:
x2=elects(:
x3=elects(:
11)./elects(:
[w1ww2]=xy2cont(lons,lats);
vnames=strvcat('
voters'
'
const'
educ'
home'
income'
res=sar(y,x,w,2100,100);
res=sar_g(y,x,w,2100,100);
prt(res,vnames);
DependentVariable=voters
R-squared=0.4402
Rbar-squared=0.4396
meanofsigedraws=0.0022
totaltimeinsecs=20.3230
timeforlndet=0.2460
timeforsampling=18.9770
***************************************************************
const-0.1331820.0126330.000000
educ0.3006530.0179860.000000
home0.7252020.0259440.000000
income-0.0082190.0010090.000000
rho0.6284070.0141160.000000
例2:
elect数据
2个权重矩阵-----W1W2
W2=slag(W1,2)bressar(sem/sac)_g
SAR(2个)SEM(2个)SAC(4个)
普通*贝叶斯共计16个模型
(注:
可对变量统一取对数)