用matlab将影响因素效应分解成直接效应、间接效应和总效应时,出现以下错误。
错误使用 zeros
Size 输入必须为整数。
出错 panel_effects_sdm (第 86 行)
total = zeros(ndraw,nvar,ntrs);
完整的运行代码如下:
A = xlsread ('E:\Matlabwork\YellowRiver\ewpinfect') ;
W1 = xlsread ('E:\Matlabwork\YellowRiver\ewpw') ;
T = 8 ;
N = 56 ;
W = normw(W1) ;
y = log(A(:,[3]));
x = log(A(:,[4:9]));
xconstant = ones(N*T,1) ;
[nobs K]=size(x) ;
for t=1:T
t1=1+(t-1)*N;t2=t*N;
wx(t1:t2,1)=W*x(t1:t2,1); %生成wx,供SDM用
end
% independent variables(双固定SDM,纠偏估计)
info.lflag=0;
info.model=3;
info.fe=0;
info.bc=1;
% New routines to calculate effects estimates
results=sar_panel_FE(y,[x wx],W,T,info);
vnames = strvcat('lny', 'lnx1', 'lnx2', 'lnx3', 'lnx4', 'lnx5', 'lnx6', 'lnx7', 'W*lnx1', 'W*lnx2', 'W*lnx3', 'W*lnx4', 'W*lnx5', 'W*lnx6', 'W*lnx7');
% Print out coefficient estimates
prt_sp(results,vnames,1);
% Print out effects estimates
panel_effects_sdm(results,vnames,W);
% needed for Hausman test later on (双固定SDM,保存供供hausman检验用)
logliklag = results.lik;
blagfe = results.parm(1:end-1);
covblagfe = results.cov(1:end-1,1:end-1);
[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,[x wx],N,T,2); % 2=time dummies
info.model=0;
results=sar_panel_RE(ywith,xwith,W,T,info);
prt_sp(results,vnames,1);
% Print out effects estimates
panel_effects_sdm(results,vnames,W);
% needed for Hausman test later on(随机效应模型 结果保存,供hausman检验用)
logliklagre=results.lik;
blagre=results.parm(1:end-2);
covblagre=results.cov(1:end-2,1:end-2);


雷达卡



京公网安备 11010802022788号







