📄 linearmodfun_gmm.m
字号:
function [error, yhat, Jstat, Jsig, vm, V, SIGB] = linearmodfun_gmm(beta);
global data1 squasher malags instlags z nwlags nwestdum arlags cthres_inf neuronxarg_inf cthres_ygap neuronxarg_ygap miny maxy maxx minx;
% beta = abs(beta);
y = data1(:,1);
x = data1(:,2:end);
[nx, cx] = size(x(:,1:2+arlags));
[nxx, cxx] = size(x);
ny = length(y);
if squasher == 1,
yy = (y - miny)/(maxy-miny);
for i = 1:cxx, xx(:,i) = (x(:,i)-minx(i))/(maxx(i)-minx(i));
end
else yy = y; xx = x;
end
yy = yy(instlags+1:end,:);
xx = xx(instlags+1:end,:);
[nxxx, cxxx] = size(xx);
yhat1 = xx(:,1:cx) * abs(beta(1:cx))' + ones(nxxx,1) * (beta(cx+1));
[nz, cz] = size(z);
if squasher == 1,
yhat = yhat1 * (maxy-miny) + miny;
else yhat = yhat1;
end;
ehat1 = y(instlags+1:end,:) - yhat;
mm = z' * ehat1 / ny;
mhat = mm(:);
mm1 = repmat(ehat1,1, cz) .* z;
S = diag(diag(cov(mm1)));
[LS, CS] = size(S);
if nwestdum == 0,
vm = S\eye(CS);
else vm = neweywest(mm1, nwlags); vm = vm\eye(CS);
end
error = mm' * vm * mm;
Jstat = error * ny;
dgf = cz - length(beta);
Jsig = 1 - chi2cdf(Jstat, dgf);
xxx = [xx(:,1:2+arlags) ones(length(xx),1)];
M = kron(eye(1),-z'*xxx/length(xxx));
V1 = inv(M' * vm * M);
V = V1 ./ nz;
SIGB = sqrt(diag(V))';
[ns, cs] = size(SIGB);
for j = 1:cs,
if SIGB(j) == 0,
SIGB(j) = .001;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -