資源簡介
空間計量的MATLAB在原來的jpl基礎上可以做面板SDM

代碼片段和文件信息
D=wk1read(‘DataOZBl.wk1‘11);?%?read?data
W1=wk1read(‘Wcex1.wk1‘);?%read?first?part?of?W
W2=wk1read(‘Wcex2.wk1‘);?%read?second?part?of?W
W3=[W1W2];?%combine?these?parts
[DA?dim]=sortrows(D[91]);
W=W3(dimdim);
clear?W1;?clear?W2;?clear?W3;?clear?D;?%?W12?3?and?D?are?not?used?any?more
W1=normw(W);?%normalize?W?routine?of?LeSage‘s?website?www.spatial-econometrics.com
lambda=eig(W1);?%eigenvalues
rmin=min(lambda);
rmax=max(lambda);
N=496;?%number?of?spatial?units
y=DA(:14);?%?dependent?variable
x=DA(:[1231012]);?%?independent?variables
const=ones(4961);
dumb=DA(:9);
duma=1-dumb;
x=[duma?dumb?x];
nvar=size(x2);
%?ols?estimator?
results=ols(yx);?%routine?from?LeSage‘s?website?www.spatial-econometrics.com
vnames=char(‘ozb‘‘duma‘‘dumb‘‘inkomen‘‘rechts‘‘taxprice‘‘lihh‘‘wrdwon‘);?%names?of?variables
prt_reg(resultsvnames);?%routine?from?LeSage‘s?website?www.spatial-econometrics.com
%?sar?one?regime?programmed?myself
n=length(y);
Wy?=?W1*y;
AI?=?x‘*x;
b0?=?AI\(x‘*y);
bd?=?AI\(x‘*Wy);
e0?=?y?-?x*b0;
ed?=?Wy?-?x*bd;
epe0?=?e0‘*e0;
eped?=?ed‘*ed;
epe0d?=?ed‘*e0;
options.Display=‘off‘;
options.MaxFunEvals=1000;
options.MaxIter=1000;
options.TolX=0.001;
options.TolFun=0.001;
rho?=?fminbnd(‘f_sarpaul‘rminrmaxoptionslambdaepe0epedepe0dn);
results.beta?=?b0?-?rho*bd;?
results.rho?=?rho;?
bhat?=?results.beta;
results.sige?=?(1/n)*(e0-rho*ed)‘*(e0-rho*ed);?
sige?=?results.sige;
results.yhat?=?(eye(n)?-?rho*W1)\(x*results.beta);
results.resid?=?y?-?results.yhat;?
parm?=?[results.beta
????????results.rho
????????results.sige];
bout=?[results.beta
????????results.rho];
results.lik?=?f2_sarpaul(parmyxW1lambda);
%?asymptotic?t-stats?based?on?information?matrix
%?(pp.?80-81?Anselin?1980)
B?=?eye(n)?-?rho*W1;?
BI?=?inv(B);?WB?=?W1*BI;
pterm?=?trace(WB*WB?+?WB*WB‘);
xpx?=?zeros(nvar+2nvar+2);???????????????%?bhatbhat
xpx(1:nvar1:nvar)?=?(1/sige)*(x‘*x);?????%?bhatrho
xpx(1:nvarnvar+1)?=?(1/sige)*x‘*W1*BI*x*bhat;
xpx(nvar+11:nvar)?=?xpx(1:nvarnvar+1)‘;?%?rhorho
xpx(nvar+1nvar+1)?=?(1/sige)*bhat‘*x‘*BI‘*W1‘*W1*BI*x*bhat?+?pterm;
xpx(nvar+2nvar+2)?=?n/(2*sige*sige);?????%sigesige
xpx(nvar+1nvar+2)?=?(1/sige)*trace(WB);??%?rhosige
xpx(nvar+2nvar+1)?=?xpx(nvar+1nvar+2);
xpxi?=?xpx\eye(size(xpx));
tmp?=?diag(xpxi(1:nvar+11:nvar+1));
bvec?=?[results.beta
????????results.rho];
tmp?=?bvec./(sqrt(tmp));
results.tstat?=?tmp;
ym?=?y?-?mean(y);???????%?r-squared?rbar-squared
rsqr1?=?results.resid‘*results.resid;
rsqr2?=?ym‘*ym;
results.rsqr?=?1.0-rsqr1/rsqr2;???%?r-squared
rsqr1?=?rsqr1/(n-nvar);
rsqr2?=?rsqr2/(n-1.0);
results.rbar?=?1?-?(rsqr1/rsqr2);?%?rbar-squared
%print
fid=1;
vnames=char(‘ozb‘‘duma‘‘dumb‘‘inkomen‘‘rechts‘‘taxprice‘‘lihh‘‘wrdwon‘‘rho‘);?%names?of?variables
fprintf(fid‘\n‘);
fprintf(fid‘sar\n‘);
fprintf(fid‘Dependent?Variable?=?%16s?\n‘vnames(1:));
fprintf(fid‘R-squared??????????=?%9.4f???\n‘results.rsqr);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2012-08-03?17:14??Elhorst_Panel_Code\
?????文件????????7529??2011-05-30?15:21??Elhorst_Panel_Code\allersdumregime.m
?????文件???????28587??2011-01-14?15:54??Elhorst_Panel_Code\cigardemo.wk1
?????文件??????124885??2011-01-14?15:53??Elhorst_Panel_Code\cigarette.wk1
?????文件???????33615??2011-05-30?13:11??Elhorst_Panel_Code\cigarette_mat.mat
?????文件????????1122??2010-01-14?09:18??Elhorst_Panel_Code\demean.m
?????文件???????10496??2011-05-30?15:10??Elhorst_Panel_Code\demodynfeerror.m
?????文件????????5938??2012-06-01?16:52??Elhorst_Panel_Code\demoLM.m
?????文件????????5482??2011-05-30?15:14??Elhorst_Panel_Code\demoLMsarsem_panel.m
?????文件???????13771??2011-05-30?12:58??Elhorst_Panel_Code\demopanelscompare.m
?????文件????????1521??2011-05-30?15:19??Elhorst_Panel_Code\demoserialspat.m
?????文件???????13937??2012-06-14?13:39??Elhorst_Panel_Code\DemoYanMin.m
?????文件????????1234??2011-06-02?15:38??Elhorst_Panel_Code\Demo_panel_sarregime.m
?????文件????????3669??2011-09-06?20:39??Elhorst_Panel_Code\direct_indirect_effects_estimates.m
?????文件????????1111??2011-09-06?20:31??Elhorst_Panel_Code\f2_resar.m
?????文件????????1320??2010-01-14?09:18??Elhorst_Panel_Code\f2_respat.m
?????文件?????????933??2010-01-14?09:18??Elhorst_Panel_Code\f2_sar2_panel.m
?????文件????????1832??2010-10-15?08:30??Elhorst_Panel_Code\f2_sarpanel.m
?????文件?????????380??2010-04-26?06:11??Elhorst_Panel_Code\f2_sarpar2.m
?????文件?????????319??2010-04-26?06:22??Elhorst_Panel_Code\f2_sarpaul.m
?????文件????????1881??2010-10-15?08:30??Elhorst_Panel_Code\f2_sempanel.m
?????文件????????1190??2010-01-14?09:18??Elhorst_Panel_Code\f2_serialspat.m
?????文件?????????782??2010-01-14?09:18??Elhorst_Panel_Code\f_resar.m
?????文件????????1242??2010-01-14?09:18??Elhorst_Panel_Code\f_respat.m
?????文件?????????847??2011-06-05?13:34??Elhorst_Panel_Code\f_sar2_panel.m
?????文件????????1915??2010-10-15?08:30??Elhorst_Panel_Code\f_sarpanel.m
?????文件?????????275??2010-04-26?06:11??Elhorst_Panel_Code\f_sarpar2.m
?????文件?????????196??2010-04-26?06:11??Elhorst_Panel_Code\f_sarpaul.m
?????文件????????1763??2010-10-15?08:30??Elhorst_Panel_Code\f_sempanel.m
?????文件????????1175??2010-01-14?09:18??Elhorst_Panel_Code\f_serialspat.m
?????文件????????1253??2010-01-14?09:18??Elhorst_Panel_Code\hessian.m
............此處省略32個文件信息
- 上一篇:移動目標檢測MATLAB版
- 下一篇:TDPlanning2.3
評論
共有 條評論