function results = sar_jihai_time(y,x,W,info)
% PURPOSE: computes spatial autoregressive model estimates
% Ynt = p*Wn*Ynt +gamma*Yn,t-1+rho*WnYn,t-1+ X*b+c +at+ e, using sparse matrix algorithms
% ---------------------------------------------------
% USAGE: results = sar(y,x,W,info)
% where: y = dependent variable vector
% x = explanatory variables matrix
% W = standardized contiguity matrix
% c=individual fixed effects
% at=time dummy effects
% info = an (optional) structure variable with input options:
% info.rmin = (optional) minimum value of rho to use in search (default = -1)
% info.rmax = (optional) maximum value of rho to use in search (default = +1)
% info.eig = 0 for default rmin = -1,rmax = +1, 1 for eigenvalue calculation of these
% info.convg = (optional) convergence criterion (default = 1e-8)
% info.maxit = (optional) maximum # of iterations (default = 500)
% info.lflag = 0 for full lndet computation (default = 1, fastest)
% = 1 for MC lndet approximation (fast for very large problems)
% = 2 for Spline lndet approximation (medium speed)
% info.order = order to use with info.lflag = 1 option (default = 50)
% info.iter = iterations to use with info.lflag = 1 option (default = 30)
% info.lndet = a matrix returned by sar, sar_g, sarp_g, etc.
% containing log-determinant information to save time
% ---------------------------------------------------
% RETURNS: a structure
% results.meth = 'sar_jihai_time'
% results.theta = estimates vector before bias correction with the
% order gammma, rho, b, p, sigma
% results.theta1 = estimates vector after bias correction with the order gammma, rho, b, p, sigma
% results.tstat = asymp t-stat (last entry is rho)
% results.bstd = std of betas (nvar x 1) vector
% results.pstd = std of rho
% results.yhat = yhat (nobs x 1) vector
% results.resid = residuals (nobs x 1) vector
% results.sige = sige
% results.rsqr = rsquared
% results.rbar = rbar-squared
% results.lik = log likelihood
% results.nobs = # of observations
% results.nvar = # of explanatory variables in x
% results.y = y data vector
% results.iter = # of iterations taken
% results.rmax = 1/max eigenvalue of W (or rmax if input)
% results.rmin = 1/min eigenvalue of W (or rmin if input)
% results.lflag = lflag from input
% results.liter = info.iter option from input
% results.order = info.order option from input
% results.limit = matrix of [rho lower95,logdet approx, upper95] intervals
% for the case of lflag = 1
% results.time1 = time for log determinant calcluation
% results.time2 = time for eigenvalue calculation
% results.time3 = time for hessian or information matrix calculation
% results.time4 = time for optimization
% results.time = total time taken
% results.lndet = a matrix containing log-determinant information
% (for use in later function calls to save time)
% --------------------------------------------------
% NOTES: if you use lflag = 1 or 2, info.rmin will be set = -1
% info.rmax will be set = 1
% For n < 1000 you should use lflag = 0 to get exact results
% --------------------------------------------------
% REFERENCES: Anselin (1988), pages 180-182.
% For lndet information see: Ronald Barry and R. Kelley Pace,
% "A Monte Carlo Estimator of the Log Determinant of Large Sparse Matrices",
% Linear Algebra and its Applications", Volume 289, Number 1-3, 1999, pp. 41-54.
% and: R. Kelley Pace and Ronald P. Barry
% "Simulating Mixed Regressive Spatially autoregressive Estimators",
% Computational Statistics, 1998, Vol. 13, pp. 397-418.
% ---------------------------------------------------
% extended by Jihai Yu, 05/23/2007, from the original code
% written by:
% James P. LeSage, 1/2000
% Dept of Economics
% University of Toledo
% 2801 W. Bancroft St,
% Toledo, OH 43606
% jlesage@spatial.econometrics.com
% NOTE: much of the speed for large problems comes from:
% the use of methods pioneered by Pace and Barry.
% R. Kelley Pace was kind enough to provide functions
% lndetmc, and lndetint from his spatial statistics toolbox
% for which I'm very grateful.
fields = fieldnames(info);
nf = length(fields);
for i=1:nf,
if strcmp(fields{i},'tl')
tl = info.tl; % tar lag index
elseif strcmp(fields{i},'stl')
stl = info.stl; % star lag index
elseif strcmp(fields{i},'ted')
ted = info.ted; % ted=1 transformation approach, =2, direct approachs
end
end
[junk n]=size(W);
[tempsize junk]=size(y);
t=tempsize/n-1;
if ted==1 %use the transformation approach
Jn=speye(n)-1/n*ones(n,1)*ones(1,n);
[Fnn junk]=eig(Jn);
F=Fnn(:,2:n);
Fy=kron(speye(t+1),F');
Fx=kron(speye(t),F');
y2=Fy*y;
if isempty(x) == 0
x2=Fx*x;
else
x2=[];
end
W2=F'*W*F;
n=n-1;
info2=struct('n',n,'t',t,'rmin',0,'rmax',1,'lflag',0,'tl',tl,'stl',stl);
res=sar_jihai(y2,x2,W2,info2);
results.meth = 'sar_jihai_time';
results.yt = res.yt;
results.nobs = res.nobs;
results.rmax = res.rmax;
results.rmin = res.rmin;
results.order = res.order;
results.miter = res.miter;
results.time1 = res.time1;
results.time2 = res.time2;
results.time3 = res.time3;
results.time4 = res.time4;
results.lndet = res.lndet;
results.lik = res.lik;
results.kz = res.kz;
results.varcov = res.varcov;
results.bias1=res.bias1;
results.SIG=res.SIG;
results.SIGi=res.SIGi;
results.OMG=res.OMG;
results.SIG1=res.SIG1;
results.SIGi1=res.SIGi1;
results.OMG1=res.OMG1;
results.theta=res.theta;
results.theta1=res.theta1;
results.tstat=res.tstat;
results.tstat1=res.tstat1;
results.std=res.std;
results.std1=res.std1;
results.rsqr=res.rsqr; %Added J.P.Elhorst, 20-4-2010
results.corr2=res.corr2; %Added J.P.Elhorst, 20-4-2010
results.zt=res.zt; %Added J.P.Elhorst, 20-4-2010
results.respaul=res.respaul; %Added J.P.Elhorst, 12-1-2016
results.respaul1=res.respaul1; %Added J.P.Elhorst, 12-1-2016
results.lik1=res.lik1; %Added J.P.Elhorst, 31-3-2016
results.resid=res.resid; %Added J.P.Elhorst, 31-3-2016
else
if ted==0
error('Wrong Info input,use sar_jihai instead as there is no time dummy');
else %ted==2, use the direct approach
Wnt=kron(speye(t),W);
nt=n*t;
yt=y(n+1:n+nt);
ytl=y(1:nt);
Q=kron(eye(t)-1/t*ones(t,1)*ones(1,t),eye(n)-1/n*ones(n,1)*ones(1,n));
yt=Q*yt;
ytl=Q*ytl;
ysl=Wnt*yt;
ystl=Wnt*ytl;
xt=x;
if isempty(x) == 0
xt=Q*xt;
else
xt=[];
end
if stl + tl == 2
zt=[ytl ystl xt];
elseif stl + tl == 1
if stl == 1, zt=[ystl xt]; else zt=[ytl xt]; end
elseif stl + tl == 0
error('Wrong Info input,Our model has dynamic term anyway');
else
error('Double-Check stl & tl # in Info structure ');
end
[junk kz]=size(zt);
[junk kx]=size(xt);
time1 = 0;
time2 = 0;
time3 = 0;
time4 = 0;
timet = clock; % start the clock for overall timing
没有合适的资源?快使用搜索试试~ 我知道了~
dynamic_spatial_panel_动态空间计量模型代码_Able_
共56个文件
m:52个
xls:2个
mat:2个
5星 · 超过95%的资源 7 下载量 105 浏览量
2021-10-02
00:44:00
上传
评论
收藏 205KB ZIP 举报
温馨提示
Dynamic space measurement code based on matlab software
资源详情
资源评论
资源推荐
收起资源包目录
dynamic_spatial_panel.zip (56个子文件)
Elhorst Cigarette Demand Book Example
f2_sacpanel.m 563B
norm_prb.m 1018B
ols.m 2KB
beta_rnd.m 1KB
log_marginal_panelprob.m 13KB
startfile.m 2KB
sar_panel_FE.m 18KB
lndetint.m 2KB
chis_cdf.m 884B
sem_panel_FE.m 15KB
f_sarpanel.m 2KB
chis_prb.m 972B
demean.m 1KB
lndetfull.m 2KB
cigarette.xls 212KB
stdn_pdf.m 967B
beta_cdf.m 1KB
f2_sarpanel.m 2KB
sem_lndet.m 2KB
lndetmc.m 3KB
beta_prior.m 1KB
prt_reg.m 15KB
mprint.m 10KB
prt_sp.m 14KB
matsub.m 1KB
normw.m 1KB
f_sempanel.m 2KB
f2_sempanel.m 2KB
Spat-Sym-US.xls 37KB
f2_sar_jihai_time.m 4KB
sac_panel_FE.m 19KB
f_sacpanel.m 494B
direct_indirect_effects_estimates.m 4KB
norm_pdf.m 1KB
sar_parse.m 3KB
sem_eigs.m 648B
A.mat 41KB
lndetexact.m 2KB
invpd.m 1KB
sar_jihai_time.m 21KB
demeanF.m 2KB
f_sar_jihai.m 2KB
handbook82_Lacombe_original.m 7KB
f2_sar_jihai.m 3KB
sem_parse.m 2KB
gamm_rnd.m 2KB
log_marginal_panelvec.m 17KB
prt_spnew.m 12KB
sar_eigs.m 648B
sar_lndet.m 2KB
norm_rnd.m 767B
sar_jihai.m 19KB
W1.mat 395B
gamm_cdf.m 798B
matdiv.m 1KB
tdis_prb.m 1003B
共 56 条
- 1
摇滚死兔子
- 粉丝: 54
- 资源: 4227
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1