-
大小: 2.07M文件类型: .zip金币: 1下载: 0 次发布日期: 2021-03-25
- 语言: Matlab
- 标签: Elhorst_Pane Elhorst Spatial econometrics prt_tests
资源简介
软件包是将New Elhorst Panel Code中的函数整合在一个文件件下,还有本人做的例子,可参考。
代码片段和文件信息
D=wk1read(‘g:\lotus\DataOZBl.wk1‘11); % read data
W1=wk1read(‘d:\allers\Wcex1.wk1‘); %read first part of W
W2=wk1read(‘d:\allers\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=strvcat(‘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=strvcat(‘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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 405172 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\A - ╕▒▒╛.mat
文件 405172 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\A.mat
文件 173267 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\A1.mat
文件 114484 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\A2.mat
文件 118920 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\A3.mat
文件 203066 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\AA.mat
文件 203674 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\AAA.mat
文件 7573 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\allersdumregime.m
文件 972 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\chis_prb.m
文件 28587 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\cigardemo.wk1
文件 124885 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\cigarette.wk1
文件 1313 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\cr_interval.m
文件 1122 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\demean.m
文件 21116 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\demodynfeerror.m
文件 6030 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\demoLM.m
文件 5932 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\demoLMsarsem_panel.m
文件 13888 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\demopanelscompare.m
文件 1545 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\demoserialspat.m
文件 3636 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\direct_indirect_effects_estimates.m
文件 1107 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f2_resar.m
文件 1320 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f2_respat.m
文件 933 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f2_sar2_panel.m
文件 1832 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f2_sarpanel.m
文件 380 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f2_sarpar2.m
文件 319 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f2_sarpaul.m
文件 1881 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f2_sempanel.m
文件 1190 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f2_serialspat.m
文件 782 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f_resar.m
文件 1242 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f_respat.m
文件 820 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f_sar2_panel.m
文件 1915 2020-09-21 03:00 ┐╒╝Σ├µ░σMATLAB\f_sarpanel.m
............此处省略71个文件信息
评论
共有 条评论