Borrar filtros
Borrar filtros

>> qardl(data, ppp, qqq, tau) Unrecognized function or variable 'data'.

7 visualizaciones (últimos 30 días)
Teboho
Teboho el 13 de Mayo de 2024
Comentada: Voss el 13 de Mayo de 2024
%-------------------------------------------------------------------------%
% This procedure file provides the following outputs
% 1) long-run parameter (beta) and its covariance matrix
% 2) short-run parameter (phi) and its covariance matrix
% 3) short-run parameter (gamma) and its covariance matrix
% For these outputs, the following inputs are required
% 1) data : (n*(1+k)) matrix, where the 1st column is the dependent
% variable, and the last k columns are explanatory variables
% 2) ppp : p value of QARDL(p,q) model
% 3) qqq : q value of QARDL(p,q) model
% 4) tau : (s*1) vector of quantiles, which is sorted from the smallest to
% the largest.
% November 17, 2020
% Jin Seo Cho
%-------------------------------------------------------------------------%
function[bigbt, bigbtmm, bigphi, bigpi, bigam, bigff] = qardl(data,ppp,qqq,tau)
nn = size(data,1);
k0 = size(data,2)-1;
ss = size(tau,1);
tau = sort(tau,1);
pd = makedist('normal','mu',0,'sigma',1);
za = icdf(pd,0.975);
hb = zeros(ss,1);
hs = zeros(ss,1);
for jj = 1:ss
hb(jj,1) = (4.5*normpdf(icdf(pd,tau(jj,1)))^4/(nn*(2*icdf(pd,tau(jj,1))^2+1)^2))^0.2;
hs(jj,1) = za^(2/3)*(1.5*normpdf(icdf(pd,tau(jj,1)))^2/(nn*(2*icdf(pd,tau(jj,1))^2+1)))^(1/3);
end
yy = data(:,1);
xx = data(:,2:size(data,2));
ee = xx(2:nn,:) - xx(1:(nn-1),:);
ee = [zeros(1,k0);ee];
eei = zeros(nn-qqq,qqq*k0);
xxi = xx(qqq+1:nn,:);
yyi = zeros(nn-ppp,ppp);
for jj = 1:k0
for ii = 0:qqq-1
eei(:, ii+1+(jj-1)*qqq) = ee((qqq+1-ii):(nn-ii),jj);
end
end
for ii = 1:ppp
yyi(:,ii) = yy((1+ppp-ii):(nn-ii),1);
end
if (ppp>qqq)
X = [eei((size(eei,1)+1-size(yyi,1)):size(eei,1),:), xxi((size(xxi,1)+1-size(yyi,1)):size(xxi,1),:), yyi];
else
X = [eei, xxi, yyi((size(yyi,1)+1-size(xxi,1)):size(yyi,1),:)];
end
% parameter estimation
ONEX = [ones(size(X,1),1),X];
Y = yy((nn-size(X,1)+1):nn,1);
bt = zeros(size(ONEX,2),ss);
fh = zeros(ss,1);
for jj = 1:ss
[bt1] = qregressMatlab(Y,ONEX,tau(jj,1));
uu = Y - ONEX*bt1;
fh(jj,1) = mean(normpdf(-uu/hb(jj,1)))/hb(jj,1);
bt(:,jj) = bt1;
end
% testing long-run parameters: beta
barw = zeros(nn-1,qqq*k0);
for jj = 1:qqq
barw(jj:(nn-1),(k0*(jj-1)+1):k0*jj) = ee(2:(nn-jj+1),:);
end
tw = [ones(nn-1,1), barw];
mm = (xx((qqq+1):nn,:)'*xx((qqq+1):nn,:) - xx((qqq+1):nn,:)'*tw(qqq:(nn-1),:)*inv(tw(qqq:(nn-1),:)'*tw(qqq:(nn-1),:))*tw(qqq:(nn-1),:)'*xx((qqq+1):nn,:))/(nn-qqq)^2;
bb = zeros(ss,1);
for jj = 1:ss
bb(jj,1) = 1/((1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)')*fh(jj,1));
end
qq = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
qq(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))*bb(jj,1)*bb(ii,1);
end
end
midbt = zeros(k0,ss);
for jj = 1:ss
midbt(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj)/(1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)');
end
bigbt = reshape(midbt,[],1);
bigbtmm = kron(qq,inv(mm));
% testing short-run parameters: phi
if (ppp>qqq)
yyj = zeros(nn-ppp,ppp);
xxj = zeros(nn-ppp,k0);
wwj = zeros(nn-ppp,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((ppp+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((ppp-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((ppp+1):nn,:);
kk = zeros(nn-ppp,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-ppp,1),xxj,wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(ii,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(ppp:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-ppp);
else
yyj = zeros(nn-qqq,ppp);
xxj = zeros(nn-qqq,k0);
wwj = zeros(nn-qqq,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((qqq+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((qqq-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((qqq+1):nn,:);
kk = zeros(nn-qqq,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-qqq,1), xxj, wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(jj,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(qqq:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-qqq);
end
cc = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
cc(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))/(fh(ii,1)*fh(jj,1));
end
end
bigpi = zeros(ss*ppp,ss*ppp);
for jj = 1:ss
for ii = 1:ss
psu = inv(lll((jj-1)*ppp+1:jj*ppp,(jj-1)*ppp+1:jj*ppp))*lll((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp)*inv(lll((ii-1)*ppp+1:ii*ppp,(ii-1)*ppp+1:ii*ppp));
bigpi((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp) = cc(jj,ii)*psu;
end
end
midphi = zeros(ppp,ss);
for jj = 1:ss
midphi(:,jj) = bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj);
end
bigphi = reshape(midphi,[],1);
% testing short-run parameters: gamma
midgam = zeros(k0,ss);
for jj = 1:ss
midgam(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj);
end
bigam = reshape(midgam,[],1);
bilam = zeros(k0*ss,ss*ppp);
for jj = 1:ss
bilam(((jj-1)*k0+1):(jj*k0),(jj-1)*ppp+1:(jj*ppp)) = midbt(:,jj)*ones(1,ppp);
end
bigff = bilam*bigpi*bilam';
end%-------------------------------------------------------------------------%
% This procedure file provides the following outputs
% 1) long-run parameter (beta) and its covariance matrix
% 2) short-run parameter (phi) and its covariance matrix
% 3) short-run parameter (gamma) and its covariance matrix
% For these outputs, the following inputs are required
% 1) data : (n*(1+k)) matrix, where the 1st column is the dependent
% variable, and the last k columns are explanatory variables
% 2) ppp : p value of QARDL(p,q) model
% 3) qqq : q value of QARDL(p,q) model
% 4) tau : (s*1) vector of quantiles, which is sorted from the smallest to
% the largest.
% November 17, 2020
% Jin Seo Cho
%-------------------------------------------------------------------------%
function[bigbt, bigbtmm, bigphi, bigpi, bigam, bigff] = qardl(data,ppp,qqq,tau)
nn = size(data,1);
k0 = size(data,2)-1;
ss = size(tau,1);
tau = sort(tau,1);
pd = makedist('normal','mu',0,'sigma',1);
za = icdf(pd,0.975);
hb = zeros(ss,1);
hs = zeros(ss,1);
for jj = 1:ss
hb(jj,1) = (4.5*normpdf(icdf(pd,tau(jj,1)))^4/(nn*(2*icdf(pd,tau(jj,1))^2+1)^2))^0.2;
hs(jj,1) = za^(2/3)*(1.5*normpdf(icdf(pd,tau(jj,1)))^2/(nn*(2*icdf(pd,tau(jj,1))^2+1)))^(1/3);
end
yy = data(:,1);
xx = data(:,2:size(data,2));
ee = xx(2:nn,:) - xx(1:(nn-1),:);
ee = [zeros(1,k0);ee];
eei = zeros(nn-qqq,qqq*k0);
xxi = xx(qqq+1:nn,:);
yyi = zeros(nn-ppp,ppp);
for jj = 1:k0
for ii = 0:qqq-1
eei(:, ii+1+(jj-1)*qqq) = ee((qqq+1-ii):(nn-ii),jj);
end
end
for ii = 1:ppp
yyi(:,ii) = yy((1+ppp-ii):(nn-ii),1);
end
if (ppp>qqq)
X = [eei((size(eei,1)+1-size(yyi,1)):size(eei,1),:), xxi((size(xxi,1)+1-size(yyi,1)):size(xxi,1),:), yyi];
else
X = [eei, xxi, yyi((size(yyi,1)+1-size(xxi,1)):size(yyi,1),:)];
end
% parameter estimation
ONEX = [ones(size(X,1),1),X];
Y = yy((nn-size(X,1)+1):nn,1);
bt = zeros(size(ONEX,2),ss);
fh = zeros(ss,1);
for jj = 1:ss
[bt1] = qregressMatlab(Y,ONEX,tau(jj,1));
uu = Y - ONEX*bt1;
fh(jj,1) = mean(normpdf(-uu/hb(jj,1)))/hb(jj,1);
bt(:,jj) = bt1;
end
% testing long-run parameters: beta
barw = zeros(nn-1,qqq*k0);
for jj = 1:qqq
barw(jj:(nn-1),(k0*(jj-1)+1):k0*jj) = ee(2:(nn-jj+1),:);
end
tw = [ones(nn-1,1), barw];
mm = (xx((qqq+1):nn,:)'*xx((qqq+1):nn,:) - xx((qqq+1):nn,:)'*tw(qqq:(nn-1),:)*inv(tw(qqq:(nn-1),:)'*tw(qqq:(nn-1),:))*tw(qqq:(nn-1),:)'*xx((qqq+1):nn,:))/(nn-qqq)^2;
bb = zeros(ss,1);
for jj = 1:ss
bb(jj,1) = 1/((1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)')*fh(jj,1));
end
qq = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
qq(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))*bb(jj,1)*bb(ii,1);
end
end
midbt = zeros(k0,ss);
for jj = 1:ss
midbt(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj)/(1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)');
end
bigbt = reshape(midbt,[],1);
bigbtmm = kron(qq,inv(mm));
% testing short-run parameters: phi
if (ppp>qqq)
yyj = zeros(nn-ppp,ppp);
xxj = zeros(nn-ppp,k0);
wwj = zeros(nn-ppp,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((ppp+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((ppp-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((ppp+1):nn,:);
kk = zeros(nn-ppp,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-ppp,1),xxj,wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(ii,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(ppp:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-ppp);
else
yyj = zeros(nn-qqq,ppp);
xxj = zeros(nn-qqq,k0);
wwj = zeros(nn-qqq,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((qqq+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((qqq-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((qqq+1):nn,:);
kk = zeros(nn-qqq,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-qqq,1), xxj, wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(jj,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(qqq:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-qqq);
end
cc = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
cc(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))/(fh(ii,1)*fh(jj,1));
end
end
bigpi = zeros(ss*ppp,ss*ppp);
for jj = 1:ss
for ii = 1:ss
psu = inv(lll((jj-1)*ppp+1:jj*ppp,(jj-1)*ppp+1:jj*ppp))*lll((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp)*inv(lll((ii-1)*ppp+1:ii*ppp,(ii-1)*ppp+1:ii*ppp));
bigpi((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp) = cc(jj,ii)*psu;
end
end
midphi = zeros(ppp,ss);
for jj = 1:ss
midphi(:,jj) = bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj);
end
bigphi = reshape(midphi,[],1);
% testing short-run parameters: gamma
midgam = zeros(k0,ss);
for jj = 1:ss
midgam(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj);
end
bigam = reshape(midgam,[],1);
bilam = zeros(k0*ss,ss*ppp);
for jj = 1:ss
bilam(((jj-1)*k0+1):(jj*k0),(jj-1)*ppp+1:(jj*ppp)) = midbt(:,jj)*ones(1,ppp);
end
bigff = bilam*bigpi*bilam';
end%-------------------------------------------------------------------------%
% This procedure file provides the following outputs
% 1) long-run parameter (beta) and its covariance matrix
% 2) short-run parameter (phi) and its covariance matrix
% 3) short-run parameter (gamma) and its covariance matrix
% For these outputs, the following inputs are required
% 1) data : (n*(1+k)) matrix, where the 1st column is the dependent
% variable, and the last k columns are explanatory variables
% 2) ppp : p value of QARDL(p,q) model
% 3) qqq : q value of QARDL(p,q) model
% 4) tau : (s*1) vector of quantiles, which is sorted from the smallest to
% the largest.
% November 17, 2020
% Jin Seo Cho
%-------------------------------------------------------------------------%
function[bigbt, bigbtmm, bigphi, bigpi, bigam, bigff] = qardl(data,ppp,qqq,tau)
nn = size(data,1);
k0 = size(data,2)-1;
ss = size(tau,1);
tau = sort(tau,1);
pd = makedist('normal','mu',0,'sigma',1);
za = icdf(pd,0.975);
hb = zeros(ss,1);
hs = zeros(ss,1);
for jj = 1:ss
hb(jj,1) = (4.5*normpdf(icdf(pd,tau(jj,1)))^4/(nn*(2*icdf(pd,tau(jj,1))^2+1)^2))^0.2;
hs(jj,1) = za^(2/3)*(1.5*normpdf(icdf(pd,tau(jj,1)))^2/(nn*(2*icdf(pd,tau(jj,1))^2+1)))^(1/3);
end
yy = data(:,1);
xx = data(:,2:size(data,2));
ee = xx(2:nn,:) - xx(1:(nn-1),:);
ee = [zeros(1,k0);ee];
eei = zeros(nn-qqq,qqq*k0);
xxi = xx(qqq+1:nn,:);
yyi = zeros(nn-ppp,ppp);
for jj = 1:k0
for ii = 0:qqq-1
eei(:, ii+1+(jj-1)*qqq) = ee((qqq+1-ii):(nn-ii),jj);
end
end
for ii = 1:ppp
yyi(:,ii) = yy((1+ppp-ii):(nn-ii),1);
end
if (ppp>qqq)
X = [eei((size(eei,1)+1-size(yyi,1)):size(eei,1),:), xxi((size(xxi,1)+1-size(yyi,1)):size(xxi,1),:), yyi];
else
X = [eei, xxi, yyi((size(yyi,1)+1-size(xxi,1)):size(yyi,1),:)];
end
% parameter estimation
ONEX = [ones(size(X,1),1),X];
Y = yy((nn-size(X,1)+1):nn,1);
bt = zeros(size(ONEX,2),ss);
fh = zeros(ss,1);
for jj = 1:ss
[bt1] = qregressMatlab(Y,ONEX,tau(jj,1));
uu = Y - ONEX*bt1;
fh(jj,1) = mean(normpdf(-uu/hb(jj,1)))/hb(jj,1);
bt(:,jj) = bt1;
end
% testing long-run parameters: beta
barw = zeros(nn-1,qqq*k0);
for jj = 1:qqq
barw(jj:(nn-1),(k0*(jj-1)+1):k0*jj) = ee(2:(nn-jj+1),:);
end
tw = [ones(nn-1,1), barw];
mm = (xx((qqq+1):nn,:)'*xx((qqq+1):nn,:) - xx((qqq+1):nn,:)'*tw(qqq:(nn-1),:)*inv(tw(qqq:(nn-1),:)'*tw(qqq:(nn-1),:))*tw(qqq:(nn-1),:)'*xx((qqq+1):nn,:))/(nn-qqq)^2;
bb = zeros(ss,1);
for jj = 1:ss
bb(jj,1) = 1/((1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)')*fh(jj,1));
end
qq = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
qq(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))*bb(jj,1)*bb(ii,1);
end
end
midbt = zeros(k0,ss);
for jj = 1:ss
midbt(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj)/(1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)');
end
bigbt = reshape(midbt,[],1);
bigbtmm = kron(qq,inv(mm));
% testing short-run parameters: phi
if (ppp>qqq)
yyj = zeros(nn-ppp,ppp);
xxj = zeros(nn-ppp,k0);
wwj = zeros(nn-ppp,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((ppp+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((ppp-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((ppp+1):nn,:);
kk = zeros(nn-ppp,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-ppp,1),xxj,wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(ii,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(ppp:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-ppp);
else
yyj = zeros(nn-qqq,ppp);
xxj = zeros(nn-qqq,k0);
wwj = zeros(nn-qqq,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((qqq+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((qqq-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((qqq+1):nn,:);
kk = zeros(nn-qqq,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-qqq,1), xxj, wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(jj,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(qqq:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-qqq);
end
cc = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
cc(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))/(fh(ii,1)*fh(jj,1));
end
end
bigpi = zeros(ss*ppp,ss*ppp);
for jj = 1:ss
for ii = 1:ss
psu = inv(lll((jj-1)*ppp+1:jj*ppp,(jj-1)*ppp+1:jj*ppp))*lll((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp)*inv(lll((ii-1)*ppp+1:ii*ppp,(ii-1)*ppp+1:ii*ppp));
bigpi((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp) = cc(jj,ii)*psu;
end
end
midphi = zeros(ppp,ss);
for jj = 1:ss
midphi(:,jj) = bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj);
end
bigphi = reshape(midphi,[],1);
% testing short-run parameters: gamma
midgam = zeros(k0,ss);
for jj = 1:ss
midgam(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj);
end
bigam = reshape(midgam,[],1);
bilam = zeros(k0*ss,ss*ppp);
for jj = 1:ss
bilam(((jj-1)*k0+1):(jj*k0),(jj-1)*ppp+1:(jj*ppp)) = midbt(:,jj)*ones(1,ppp);
end
bigff = bilam*bigpi*bilam';
end%-------------------------------------------------------------------------%
% This procedure file provides the following outputs
% 1) long-run parameter (beta) and its covariance matrix
% 2) short-run parameter (phi) and its covariance matrix
% 3) short-run parameter (gamma) and its covariance matrix
% For these outputs, the following inputs are required
% 1) data : (n*(1+k)) matrix, where the 1st column is the dependent
% variable, and the last k columns are explanatory variables
% 2) ppp : p value of QARDL(p,q) model
% 3) qqq : q value of QARDL(p,q) model
% 4) tau : (s*1) vector of quantiles, which is sorted from the smallest to
% the largest.
% November 17, 2020
% Jin Seo Cho
%-------------------------------------------------------------------------%
function[bigbt, bigbtmm, bigphi, bigpi, bigam, bigff] = qardl(data,ppp,qqq,tau)
nn = size(data,1);
k0 = size(data,2)-1;
ss = size(tau,1);
tau = sort(tau,1);
pd = makedist('normal','mu',0,'sigma',1);
za = icdf(pd,0.975);
hb = zeros(ss,1);
hs = zeros(ss,1);
for jj = 1:ss
hb(jj,1) = (4.5*normpdf(icdf(pd,tau(jj,1)))^4/(nn*(2*icdf(pd,tau(jj,1))^2+1)^2))^0.2;
hs(jj,1) = za^(2/3)*(1.5*normpdf(icdf(pd,tau(jj,1)))^2/(nn*(2*icdf(pd,tau(jj,1))^2+1)))^(1/3);
end
yy = data(:,1);
xx = data(:,2:size(data,2));
ee = xx(2:nn,:) - xx(1:(nn-1),:);
ee = [zeros(1,k0);ee];
eei = zeros(nn-qqq,qqq*k0);
xxi = xx(qqq+1:nn,:);
yyi = zeros(nn-ppp,ppp);
for jj = 1:k0
for ii = 0:qqq-1
eei(:, ii+1+(jj-1)*qqq) = ee((qqq+1-ii):(nn-ii),jj);
end
end
for ii = 1:ppp
yyi(:,ii) = yy((1+ppp-ii):(nn-ii),1);
end
if (ppp>qqq)
X = [eei((size(eei,1)+1-size(yyi,1)):size(eei,1),:), xxi((size(xxi,1)+1-size(yyi,1)):size(xxi,1),:), yyi];
else
X = [eei, xxi, yyi((size(yyi,1)+1-size(xxi,1)):size(yyi,1),:)];
end
% parameter estimation
ONEX = [ones(size(X,1),1),X];
Y = yy((nn-size(X,1)+1):nn,1);
bt = zeros(size(ONEX,2),ss);
fh = zeros(ss,1);
for jj = 1:ss
[bt1] = qregressMatlab(Y,ONEX,tau(jj,1));
uu = Y - ONEX*bt1;
fh(jj,1) = mean(normpdf(-uu/hb(jj,1)))/hb(jj,1);
bt(:,jj) = bt1;
end
% testing long-run parameters: beta
barw = zeros(nn-1,qqq*k0);
for jj = 1:qqq
barw(jj:(nn-1),(k0*(jj-1)+1):k0*jj) = ee(2:(nn-jj+1),:);
end
tw = [ones(nn-1,1), barw];
mm = (xx((qqq+1):nn,:)'*xx((qqq+1):nn,:) - xx((qqq+1):nn,:)'*tw(qqq:(nn-1),:)*inv(tw(qqq:(nn-1),:)'*tw(qqq:(nn-1),:))*tw(qqq:(nn-1),:)'*xx((qqq+1):nn,:))/(nn-qqq)^2;
bb = zeros(ss,1);
for jj = 1:ss
bb(jj,1) = 1/((1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)')*fh(jj,1));
end
qq = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
qq(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))*bb(jj,1)*bb(ii,1);
end
end
midbt = zeros(k0,ss);
for jj = 1:ss
midbt(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj)/(1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)');
end
bigbt = reshape(midbt,[],1);
bigbtmm = kron(qq,inv(mm));
% testing short-run parameters: phi
if (ppp>qqq)
yyj = zeros(nn-ppp,ppp);
xxj = zeros(nn-ppp,k0);
wwj = zeros(nn-ppp,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((ppp+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((ppp-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((ppp+1):nn,:);
kk = zeros(nn-ppp,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-ppp,1),xxj,wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(ii,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(ppp:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-ppp);
else
yyj = zeros(nn-qqq,ppp);
xxj = zeros(nn-qqq,k0);
wwj = zeros(nn-qqq,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((qqq+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((qqq-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((qqq+1):nn,:);
kk = zeros(nn-qqq,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-qqq,1), xxj, wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(jj,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(qqq:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-qqq);
end
cc = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
cc(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))/(fh(ii,1)*fh(jj,1));
end
end
bigpi = zeros(ss*ppp,ss*ppp);
for jj = 1:ss
for ii = 1:ss
psu = inv(lll((jj-1)*ppp+1:jj*ppp,(jj-1)*ppp+1:jj*ppp))*lll((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp)*inv(lll((ii-1)*ppp+1:ii*ppp,(ii-1)*ppp+1:ii*ppp));
bigpi((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp) = cc(jj,ii)*psu;
end
end
midphi = zeros(ppp,ss);
for jj = 1:ss
midphi(:,jj) = bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj);
end
bigphi = reshape(midphi,[],1);
% testing short-run parameters: gamma
midgam = zeros(k0,ss);
for jj = 1:ss
midgam(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj);
end
bigam = reshape(midgam,[],1);
bilam = zeros(k0*ss,ss*ppp);
for jj = 1:ss
bilam(((jj-1)*k0+1):(jj*k0),(jj-1)*ppp+1:(jj*ppp)) = midbt(:,jj)*ones(1,ppp);
end
bigff = bilam*bigpi*bilam';
end%-------------------------------------------------------------------------%
% This procedure file provides the following outputs
% 1) long-run parameter (beta) and its covariance matrix
% 2) short-run parameter (phi) and its covariance matrix
% 3) short-run parameter (gamma) and its covariance matrix
% For these outputs, the following inputs are required
% 1) data : (n*(1+k)) matrix, where the 1st column is the dependent
% variable, and the last k columns are explanatory variables
% 2) ppp : p value of QARDL(p,q) model
% 3) qqq : q value of QARDL(p,q) model
% 4) tau : (s*1) vector of quantiles, which is sorted from the smallest to
% the largest.
% November 17, 2020
% Jin Seo Cho
%-------------------------------------------------------------------------%
function[bigbt, bigbtmm, bigphi, bigpi, bigam, bigff] = qardl(data,ppp,qqq,tau)
nn = size(data,1);
k0 = size(data,2)-1;
ss = size(tau,1);
tau = sort(tau,1);
pd = makedist('normal','mu',0,'sigma',1);
za = icdf(pd,0.975);
hb = zeros(ss,1);
hs = zeros(ss,1);
for jj = 1:ss
hb(jj,1) = (4.5*normpdf(icdf(pd,tau(jj,1)))^4/(nn*(2*icdf(pd,tau(jj,1))^2+1)^2))^0.2;
hs(jj,1) = za^(2/3)*(1.5*normpdf(icdf(pd,tau(jj,1)))^2/(nn*(2*icdf(pd,tau(jj,1))^2+1)))^(1/3);
end
yy = data(:,1);
xx = data(:,2:size(data,2));
ee = xx(2:nn,:) - xx(1:(nn-1),:);
ee = [zeros(1,k0);ee];
eei = zeros(nn-qqq,qqq*k0);
xxi = xx(qqq+1:nn,:);
yyi = zeros(nn-ppp,ppp);
for jj = 1:k0
for ii = 0:qqq-1
eei(:, ii+1+(jj-1)*qqq) = ee((qqq+1-ii):(nn-ii),jj);
end
end
for ii = 1:ppp
yyi(:,ii) = yy((1+ppp-ii):(nn-ii),1);
end
if (ppp>qqq)
X = [eei((size(eei,1)+1-size(yyi,1)):size(eei,1),:), xxi((size(xxi,1)+1-size(yyi,1)):size(xxi,1),:), yyi];
else
X = [eei, xxi, yyi((size(yyi,1)+1-size(xxi,1)):size(yyi,1),:)];
end
% parameter estimation
ONEX = [ones(size(X,1),1),X];
Y = yy((nn-size(X,1)+1):nn,1);
bt = zeros(size(ONEX,2),ss);
fh = zeros(ss,1);
for jj = 1:ss
[bt1] = qregressMatlab(Y,ONEX,tau(jj,1));
uu = Y - ONEX*bt1;
fh(jj,1) = mean(normpdf(-uu/hb(jj,1)))/hb(jj,1);
bt(:,jj) = bt1;
end
% testing long-run parameters: beta
barw = zeros(nn-1,qqq*k0);
for jj = 1:qqq
barw(jj:(nn-1),(k0*(jj-1)+1):k0*jj) = ee(2:(nn-jj+1),:);
end
tw = [ones(nn-1,1), barw];
mm = (xx((qqq+1):nn,:)'*xx((qqq+1):nn,:) - xx((qqq+1):nn,:)'*tw(qqq:(nn-1),:)*inv(tw(qqq:(nn-1),:)'*tw(qqq:(nn-1),:))*tw(qqq:(nn-1),:)'*xx((qqq+1):nn,:))/(nn-qqq)^2;
bb = zeros(ss,1);
for jj = 1:ss
bb(jj,1) = 1/((1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)')*fh(jj,1));
end
qq = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
qq(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))*bb(jj,1)*bb(ii,1);
end
end
midbt = zeros(k0,ss);
for jj = 1:ss
midbt(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj)/(1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)');
end
bigbt = reshape(midbt,[],1);
bigbtmm = kron(qq,inv(mm));
% testing short-run parameters: phi
if (ppp>qqq)
yyj = zeros(nn-ppp,ppp);
xxj = zeros(nn-ppp,k0);
wwj = zeros(nn-ppp,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((ppp+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((ppp-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((ppp+1):nn,:);
kk = zeros(nn-ppp,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-ppp,1),xxj,wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(ii,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(ppp:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-ppp);
else
yyj = zeros(nn-qqq,ppp);
xxj = zeros(nn-qqq,k0);
wwj = zeros(nn-qqq,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((qqq+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((qqq-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((qqq+1):nn,:);
kk = zeros(nn-qqq,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-qqq,1), xxj, wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(jj,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(qqq:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-qqq);
end
cc = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
cc(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))/(fh(ii,1)*fh(jj,1));
end
end
bigpi = zeros(ss*ppp,ss*ppp);
for jj = 1:ss
for ii = 1:ss
psu = inv(lll((jj-1)*ppp+1:jj*ppp,(jj-1)*ppp+1:jj*ppp))*lll((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp)*inv(lll((ii-1)*ppp+1:ii*ppp,(ii-1)*ppp+1:ii*ppp));
bigpi((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp) = cc(jj,ii)*psu;
end
end
midphi = zeros(ppp,ss);
for jj = 1:ss
midphi(:,jj) = bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj);
end
bigphi = reshape(midphi,[],1);
% testing short-run parameters: gamma
midgam = zeros(k0,ss);
for jj = 1:ss
midgam(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj);
end
bigam = reshape(midgam,[],1);
bilam = zeros(k0*ss,ss*ppp);
for jj = 1:ss
bilam(((jj-1)*k0+1):(jj*k0),(jj-1)*ppp+1:(jj*ppp)) = midbt(:,jj)*ones(1,ppp);
end
bigff = bilam*bigpi*bilam';
end

Respuestas (1)

Voss
Voss el 13 de Mayo de 2024
To run this function, you'd need to supply the inputs data, ppp, qqq, and tau. These are described in the comments at the top of the function:
% 1) data : (n*(1+k)) matrix, where the 1st column is the dependent
% variable, and the last k columns are explanatory variables
% 2) ppp : p value of QARDL(p,q) model
% 3) qqq : q value of QARDL(p,q) model
% 4) tau : (s*1) vector of quantiles, which is sorted from the smallest to
% the largest.
  2 comentarios
Teboho
Teboho el 13 de Mayo de 2024
@Voss, I am not familier with Matlab. can you give a hint on how to supply that. my programing is very poor.
data : demo1
ppp : 2
qqq : 2
tau : 0.5 0.10 0.90
is this i am suppose to input the arguments?
Voss
Voss el 13 de Mayo de 2024
I don't know what a QARDL(p,q) model is, so I suspect any example inputs I come up with would be pretty much useless (nevertheless, see below).
Maybe check with the person or website you got the qardl function from, and see if there are any references that show examples of how to run it.
Also, note that the qardl function is defined 5 times in the code in your question; it looks like the same code repeated 5 times (I didn't verify that). You should only define it one time.
% here's an example attempting to run qardl
% with some random (and possibly nonsensical) inputs:
data = rand(5,8);
ppp = 100;
qqq = 75;
tau = [1;2;3];
[bigbt, bigbtmm, bigphi, bigpi, bigam, bigff] = qardl(data,ppp,qqq,tau)
Unrecognized function or variable 'qregressMatlab'.

Error in solution>qardl (line 65)
[bt1] = qregressMatlab(Y,ONEX,tau(jj,1));
%-------------------------------------------------------------------------%
% This procedure file provides the following outputs
% 1) long-run parameter (beta) and its covariance matrix
% 2) short-run parameter (phi) and its covariance matrix
% 3) short-run parameter (gamma) and its covariance matrix
% For these outputs, the following inputs are required
% 1) data : (n*(1+k)) matrix, where the 1st column is the dependent
% variable, and the last k columns are explanatory variables
% 2) ppp : p value of QARDL(p,q) model
% 3) qqq : q value of QARDL(p,q) model
% 4) tau : (s*1) vector of quantiles, which is sorted from the smallest to
% the largest.
% November 17, 2020
% Jin Seo Cho
%-------------------------------------------------------------------------%
function[bigbt, bigbtmm, bigphi, bigpi, bigam, bigff] = qardl(data,ppp,qqq,tau)
nn = size(data,1);
k0 = size(data,2)-1;
ss = size(tau,1);
tau = sort(tau,1);
pd = makedist('normal','mu',0,'sigma',1);
za = icdf(pd,0.975);
hb = zeros(ss,1);
hs = zeros(ss,1);
for jj = 1:ss
hb(jj,1) = (4.5*normpdf(icdf(pd,tau(jj,1)))^4/(nn*(2*icdf(pd,tau(jj,1))^2+1)^2))^0.2;
hs(jj,1) = za^(2/3)*(1.5*normpdf(icdf(pd,tau(jj,1)))^2/(nn*(2*icdf(pd,tau(jj,1))^2+1)))^(1/3);
end
yy = data(:,1);
xx = data(:,2:size(data,2));
ee = xx(2:nn,:) - xx(1:(nn-1),:);
ee = [zeros(1,k0);ee];
eei = zeros(nn-qqq,qqq*k0);
xxi = xx(qqq+1:nn,:);
yyi = zeros(nn-ppp,ppp);
for jj = 1:k0
for ii = 0:qqq-1
eei(:, ii+1+(jj-1)*qqq) = ee((qqq+1-ii):(nn-ii),jj);
end
end
for ii = 1:ppp
yyi(:,ii) = yy((1+ppp-ii):(nn-ii),1);
end
if (ppp>qqq)
X = [eei((size(eei,1)+1-size(yyi,1)):size(eei,1),:), xxi((size(xxi,1)+1-size(yyi,1)):size(xxi,1),:), yyi];
else
X = [eei, xxi, yyi((size(yyi,1)+1-size(xxi,1)):size(yyi,1),:)];
end
% parameter estimation
ONEX = [ones(size(X,1),1),X];
Y = yy((nn-size(X,1)+1):nn,1);
bt = zeros(size(ONEX,2),ss);
fh = zeros(ss,1);
for jj = 1:ss
[bt1] = qregressMatlab(Y,ONEX,tau(jj,1));
uu = Y - ONEX*bt1;
fh(jj,1) = mean(normpdf(-uu/hb(jj,1)))/hb(jj,1);
bt(:,jj) = bt1;
end
% testing long-run parameters: beta
barw = zeros(nn-1,qqq*k0);
for jj = 1:qqq
barw(jj:(nn-1),(k0*(jj-1)+1):k0*jj) = ee(2:(nn-jj+1),:);
end
tw = [ones(nn-1,1), barw];
mm = (xx((qqq+1):nn,:)'*xx((qqq+1):nn,:) - xx((qqq+1):nn,:)'*tw(qqq:(nn-1),:)*inv(tw(qqq:(nn-1),:)'*tw(qqq:(nn-1),:))*tw(qqq:(nn-1),:)'*xx((qqq+1):nn,:))/(nn-qqq)^2;
bb = zeros(ss,1);
for jj = 1:ss
bb(jj,1) = 1/((1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)')*fh(jj,1));
end
qq = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
qq(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))*bb(jj,1)*bb(ii,1);
end
end
midbt = zeros(k0,ss);
for jj = 1:ss
midbt(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj)/(1-sum(bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj),1)');
end
bigbt = reshape(midbt,[],1);
bigbtmm = kron(qq,inv(mm));
% testing short-run parameters: phi
if (ppp>qqq)
yyj = zeros(nn-ppp,ppp);
xxj = zeros(nn-ppp,k0);
wwj = zeros(nn-ppp,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((ppp+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((ppp-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((ppp+1):nn,:);
kk = zeros(nn-ppp,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-ppp,1),xxj,wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(ii,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(ppp:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-ppp);
else
yyj = zeros(nn-qqq,ppp);
xxj = zeros(nn-qqq,k0);
wwj = zeros(nn-qqq,qqq*k0);
for jj = 1:ppp
yyj(:,jj) = yy((qqq+1-jj):(nn-jj),1);
end
for ii = 1:k0
for jj = 1:qqq
wwj(:,jj+(ii-1)*qqq) = ee((qqq-jj+2):(nn-jj+1),ii);
end
end
xxj = xx((qqq+1):nn,:);
kk = zeros(nn-qqq,ss*ppp);
for jj = 1:ppp
Y = yyj(:,jj);
ONEX = [ones(nn-qqq,1), xxj, wwj];
for ii = 1:ss
[bbt] = qregressMatlab(Y,ONEX,tau(jj,1));
kkk = Y - ONEX*bbt;
kk(:,jj+(ii-1)*ppp) = kkk;
end
end
tilw = tw(qqq:(nn-1),:);
lll = (kk'*kk - kk'*tilw*inv(tilw'*tilw)*tilw'*kk)/(nn-qqq);
end
cc = zeros(ss,ss);
for jj = 1:ss
for ii = 1:ss
psu = zeros(2,1);
psu(1,1) = tau(jj,1);
psu(2,1) = tau(ii,1);
cc(jj,ii) = (min(psu,[],1)' - tau(jj,1)*tau(ii,1))/(fh(ii,1)*fh(jj,1));
end
end
bigpi = zeros(ss*ppp,ss*ppp);
for jj = 1:ss
for ii = 1:ss
psu = inv(lll((jj-1)*ppp+1:jj*ppp,(jj-1)*ppp+1:jj*ppp))*lll((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp)*inv(lll((ii-1)*ppp+1:ii*ppp,(ii-1)*ppp+1:ii*ppp));
bigpi((jj-1)*ppp+1:jj*ppp,(ii-1)*ppp+1:ii*ppp) = cc(jj,ii)*psu;
end
end
midphi = zeros(ppp,ss);
for jj = 1:ss
midphi(:,jj) = bt(2+(qqq+1)*k0:1+(qqq+1)*k0+ppp,jj);
end
bigphi = reshape(midphi,[],1);
% testing short-run parameters: gamma
midgam = zeros(k0,ss);
for jj = 1:ss
midgam(:,jj) = bt(2+qqq*k0:1+(qqq+1)*k0,jj);
end
bigam = reshape(midgam,[],1);
bilam = zeros(k0*ss,ss*ppp);
for jj = 1:ss
bilam(((jj-1)*k0+1):(jj*k0),(jj-1)*ppp+1:(jj*ppp)) = midbt(:,jj)*ones(1,ppp);
end
bigff = bilam*bigpi*bilam';
end

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by