필터 지우기
필터 지우기

MATRIX ARRANGEMENT PROBLEM MATLAB

조회 수: 1 (최근 30일)
Saptorshee Chakraborty
Saptorshee Chakraborty 2022년 6월 14일
편집: Cris LaPierre 2022년 6월 16일
Hello,
I am working with panel structural breaks, where , and X1, X2, X3 (d=3).
Now I have three breaks, B=3, while the author uses the code with B=1 and GB, GA (for me it will be GI, GII, GIII, GIV)
I am stuck at T_frac, Y_frac, X_frac somehow the index becomes more than 3.
I am permission to use the code of the author, any help will be appreciated.
Xvec = [x1, x2, x3];
Yvec = y;
N=114;
TT=48;
xlag = x(:,1:TT-1,:);
ylag = y(:,2:TT);
T = TT-1;
Xmat = xlag;
ymat = ylag;
p = size(Xmat,3);
S = 30;
SSR = zeros(1,(T-2));
SSR(1) = inf;
ymatfd = diff(ymat,1,2);
Xmatfd = diff(Xmat,1,2);
for j = 1:B
for bk = 2:(T-2)
regime = [0,bk,T-1]; % Get the bounds of potential subperiods
for aa = 1:(j+1)
T_frac = length((regime(aa)+1):(regime(aa+1)));
y_frac = reshape(ymatfd(:,(regime(aa)+1):(regime(aa+1)))',N*T_frac,1);
for l = 1:p
X_frac(:,l) = reshape(Xmatfd(:,(regime(aa)+1):(regime(aa+1)),l)',N*T_frac,1);
end
time_frac = repmat(1:T_frac,1,N)';
code_frac = kron((1:N)',ones(T_frac,1));
idxdata_frac = dataset(code_frac, time_frac, y_frac, X_frac);
idxdata_frac.Properties.VarNames = {'N' 'T' 'y' 'X'};
if aa == 1
[~,~,ssr,] = est_group(idxdata_frac,GB);
elseif aa == 2
[~,~,ssr,] = est_group(idxdata_frac,GA);
end
SSR(bk) = SSR(bk) + ssr;
clear X_frac y_frac idxdata_frac time_frac code_frac
end
end
[resQ,k] = min(SSR); % Compare SSR to get a breakdate
end
  댓글 수: 2
Jan
Jan 2022년 6월 14일
"Now I have three breaks, B=3, while the author uses the code with B=1 and GB, GA (for me it will be GI, GII, GIII, GIV)" - remember, that the readers do not know, what you are talking off. Who is the autheor? What us GB and GA, GI, GII, GIII and GIV?
What does this mean: "I am stuck at T_frac, Y_frac, X_frac somehow the index becomes more than 3."?
Saptorshee Chakraborty
Saptorshee Chakraborty 2022년 6월 14일
When I compute using B=3.

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2022년 6월 14일
Not that your loop counter is j, but your indexing uses j+1, and then again use loop counter aa, but index using aa+1. Therefore, when B=3, j+1=4 and aa+1=5.
for j = 1:B
...
for aa = 1:(j+1)
T_frac = length((regime(aa)+1):(regime(aa+1)));
% ^^^^
end
end
  댓글 수: 12
Cris LaPierre
Cris LaPierre 2022년 6월 16일
편집: Cris LaPierre 2022년 6월 16일
I didn't mention a fix. I just pointed out the code that was causing the problem.
The fix is to make regime longer. It needs to be a 1x(B+2) vector to not error. Again, it is currently 1x3, so when B=1, the code works. When B=3, it needs to be 1x5.
I don't know what values to add, though. That is something where you would need to apply your knowledge in this space to corectly adjust the code.
Saptorshee Chakraborty
Saptorshee Chakraborty 2022년 6월 16일
Thank you very much indeed, I appreciate your help.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by