sur: fix bug in creation of SUR matrices; handle random walk equation regardless of order in model equations
parent
cf0d8f319e
commit
875381379f
|
@ -47,21 +47,19 @@ for i = 1:neqs
|
||||||
% X{i} is empty for AR(1) equations
|
% X{i} is empty for AR(1) equations
|
||||||
assert(size(X{i}, 1) == size(Y{i}, 1), 'Y{i} and X{i} must have the same nuber of observations');
|
assert(size(X{i}, 1) == size(Y{i}, 1), 'Y{i} and X{i} must have the same nuber of observations');
|
||||||
end
|
end
|
||||||
nobs(i) = size(X{i}, 1);
|
nobs(i) = size(Y{i}, 1);
|
||||||
end
|
end
|
||||||
|
fd = Y{1}.firstdate;
|
||||||
nrows = sum(nobs);
|
nrows = sum(nobs);
|
||||||
Xmat = dseries([X{1}.data; zeros(nrows-nobs(1), size(X{1}, 2))], X{1}.firstdate, X{1}.name);
|
Xmat = dseries();
|
||||||
Yvec = Y{1};
|
Yvec = dseries();
|
||||||
constrained = {};
|
constrained = {};
|
||||||
for i = 2:neqs
|
for i = 1:neqs
|
||||||
if isempty(X{i})
|
if ~isempty(X{i})
|
||||||
data = [Xmat.data;zeros(size(Y{i},1), size(Xmat.data, 2))];
|
|
||||||
Xmat = dseries(data, X{1}.firstdate, Xmat.name);
|
|
||||||
else
|
|
||||||
to_remove = [];
|
to_remove = [];
|
||||||
nr = sum(nobs(1:i-1));
|
nr = sum(nobs(1:i-1));
|
||||||
nxcol = size(X{i}, 2);
|
nxcol = size(X{i}, 2);
|
||||||
Xtmp = dseries([zeros(nr, nxcol); X{i}.data; zeros(nrows-nr-nobs(i), nxcol)], X{1}.firstdate, X{i}.name);
|
Xtmp = dseries([zeros(nr, nxcol); X{i}.data; zeros(nrows-nr-nobs(i), nxcol)], fd, X{i}.name);
|
||||||
for j = 1:length(X{i}.name)
|
for j = 1:length(X{i}.name)
|
||||||
idx = find(strcmp(Xmat.name, X{i}.name{j}));
|
idx = find(strcmp(Xmat.name, X{i}.name{j}));
|
||||||
if ~isempty(idx)
|
if ~isempty(idx)
|
||||||
|
@ -77,6 +75,7 @@ for i = 2:neqs
|
||||||
Xmat = [Xmat Xtmp];
|
Xmat = [Xmat Xtmp];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Yvec = dseries([Yvec.data; Y{i}.data], Yvec.firstdate);
|
Yvec = dseries([Yvec.data; Y{i}.data], fd);
|
||||||
end
|
end
|
||||||
|
assert(size(Y, 1) == size(X, 1));
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue