Not enough Input arguments

1 Ansicht (letzte 30 Tage)
sanjiv kumar
sanjiv kumar am 13 Okt. 2021
Kommentiert: sanjiv kumar am 13 Okt. 2021
Dear Matlab experts, while running the code i am getting an error, if anyone of you could help i would be really greatful.
The error i am getting
--------------------------------------------------------------------------------------------------
>>qardlecm
Not enough input arguments.
Error in qardlecm (line 24)
nn = size(data,1);
...................................................
--The code I want to run---------------------------------------------------------------------------------------------------------------------------------------------------------
%-------------------------------------------------------------------------%
% This procedure file provides the following outputs
% Short-run parameters (phi, theta) and its covariance matrix
% For this output, 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-ECM(p,q) model
% 3) qqq : q value of QARDL-ECM(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[bigphia,bigpia,thett,distthett] = qardlecm(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
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);
uu = zeros(nn-2,ss);
for jj = 1:ss
[bt1] = qregressMatlab(Y,ONEX,tau(jj,1));
uu(:,jj) = Y - ONEX*bt1;
fh(jj,1) = mean(normpdf(-uu(:,jj)/hb(jj,1)))/hb(jj,1);
bt(:,jj) = bt1;
end
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));
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
kka1 = kk(:,2);
kka2 = kk(:,4);
kka3 = kk(:,6);
kka = [kka1,kka2,kka3];
tilw = tw(ppp:(nn-1),:);
llla = (kka'*kka - kka'*tilw*inv(tilw'*tilw)*tilw'*kka)/(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
kka1 = kk(:,2);
kka2 = kk(:,4);
kka3 = kk(:,6);
kka = [kka1,kka2,kka3];
tilw = tw(qqq:(nn-1),:);
llla = (kka'*kka - kka'*tilw*inv(tilw'*tilw)*tilw'*kka)/(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
bigpia = zeros(ss*(ppp-1),ss*(ppp-1));
for jj = 1:ss
for ii = 1:ss
psu = inv(llla((jj-1)*(ppp-1)+1:jj*(ppp-1),(jj-1)*(ppp-1)+1:jj*(ppp-1)))*llla((jj-1)*(ppp-1)+1:jj*(ppp-1),(ii-1)*(ppp-1)+1:ii*(ppp-1))*inv(llla((ii-1)*(ppp-1)+1:ii*(ppp-1),(ii-1)*(ppp-1)+1:ii*(ppp-1)));
bigpia((jj-1)*(ppp-1)+1:jj*(ppp-1),(ii-1)*(ppp-1)+1:ii*(ppp-1)) = 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);
bigphia1 = bigphi(2,1);
bigphia2 = bigphi(4,1);
bigphia3 = bigphi(6,1);
bigphia = [bigphia1; bigphia2; bigphia3];
dg = [nn^(1/2),0,0; 0,nn^(1/2),0; 0,0,nn];
uu2 = uu;
tilwb = tilw(:,2);
r1 = 1;
r2 = sum(tilwb,1)*(nn-2)^(-1);
r3 = sum(xx(3:nn,1),1)*(nn-2)^(-3/2);
r4 = r2;
rh5 = tilwb'*tilwb;
r5 = rh5*(nn-2)^(-1);
rh6 = tilwb'*xx(3:nn,1);
r6 = rh6*(nn-2)^(-3/2);
r7 = r3;
r8 = r6;
rh9 = xx(3:nn,1)'*xx(3:nn,1);
r9 = rh9*(nn-2)^(-2);
QQQ = [r1, r2, r3 ; r4, r5, r6; r7, r8, r9];
psiu = zeros(nn-2,3);
for jj = 1:3
for rr = 1:nn-2
if (uu2(rr,jj)<= 0)
psiu(rr,jj) = tau(jj,1)-1;
else
psiu(rr,jj) = tau(jj,1);
end
end
end
sigmma = psiu'*psiu*(1/(nn-2));
psiu1 = psiu(1:nn-2,1);
psiu2 = psiu(1:nn-2,2);
psiu3 = psiu(1:nn-2,3);
sium1 = mean(psiu1);
sium2 = mean(psiu2);
sium3 = mean(psiu3);
sigma1 = mean(psiu1.^(2));
sigma2 = mean(psiu2.^(2));
sigma3 = mean(psiu3.^(2));
distmt1 = nn*fh(1,1)^(-2)*sigmma(1,1)*inv(dg)*inv(QQQ)*inv(dg);
distmt2 = nn*fh(1,1)^(-1)*fh(2,1)^(-1)*sigmma(1,2)*inv(dg)*inv(QQQ)*inv(dg);
distmt3 = nn*fh(1,1)^(-1)*fh(3,1)^(-1)*sigmma(1,3)*inv(dg)*inv(QQQ)*inv(dg);
distmt4 = nn*fh(2,1)^(-1)*fh(1,1)^(-1)*sigmma(2,1)*inv(dg)*inv(QQQ)*inv(dg);
distmt5 = nn*fh(2,1)^(-2)*sigmma(2,2)*inv(dg)*inv(QQQ)*inv(dg);
distmt6 = nn*fh(2,1)^(-1)*fh(3,1)^(-1)*sigmma(2,3)*inv(dg)*inv(QQQ)*inv(dg);
distmt7 = nn*fh(3,1)^(-1)*fh(1,1)^(-1)*sigmma(3,1)*inv(dg)*inv(QQQ)*inv(dg);
distmt8 = nn*fh(3,1)^(-1)*fh(2,1)^(-1)*sigmma(3,2)*inv(dg)*inv(QQQ)*inv(dg);
distmt9 = nn*fh(3,1)^(-2)*sigmma(3,3)*inv(dg)*inv(QQQ)*inv(dg);
A11 = distmt1(2,2);
A12 = distmt1(3,3);
A13 = 2*distmt1(2,3);
A21 = distmt2(2,2);
A22 = distmt2(3,3);
A23 = 2*distmt2(2,3);
A31 = distmt3(2,2);
A32 = distmt3(3,3);
A33 = 2*distmt3(2,3);
A41 = distmt4(2,2);
A42 = distmt4(3,3);
A43 = 2*distmt4(2,3);
A51 = distmt5(2,2);
A52 = distmt5(3,3);
A53 = 2*distmt5(2,3);
A61 = distmt6(2,2);
A62 = distmt6(3,3);
A63 = 2*distmt6(2,3);
A71 = distmt7(2,2);
A72 = distmt7(3,3);
A73 = 2*distmt7(2,3);
A81 = distmt8(2,2);
A82 = distmt8(3,3);
A83 = 2*distmt8(2,3);
A91 = distmt9(2,2);
A92 = distmt9(3,3);
A93 = 2*distmt9(2,3);
distcon1 = A11 + A12 + A13;
distcon2 = A21 + A22 + A23;
distcon3 = A31 + A32 + A33;
distcon4 = A41 + A42 + A43;
distcon5 = A51 + A52 + A53;
distcon6 = A61 + A62 + A63;
distcon7 = A71 + A72 + A73;
distcon8 = A81 + A82 + A83;
distcon9 = A91 + A92 + A93;
distthett = [distcon1, distcon2, distcon3 ; distcon4, distcon5, distcon6 ; distcon7, distcon8, distcon9];
thett1 = bt(2,1) + bt(3,1);
thett2 = bt(2,2) + bt(3,2);
thett3 = bt(2,3) + bt(3,3);
thett = [thett1 ; thett2 ; thett3];
end
  2 Kommentare
Stephen23
Stephen23 am 13 Okt. 2021
Bearbeitet: Stephen23 am 13 Okt. 2021
qardlecm requires four inout arguments when it is called. What inputs are you supplying when you call it?
sanjiv kumar
sanjiv kumar am 13 Okt. 2021
Thank you so much. Now I have got the answer, I was not providing all the four input as it requires. Now I am able to run the code.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 13 Okt. 2021
Stephen hits the point:
>>qardlecm
This shows, that you call the function without input arguments. Perhaps you start it by clicking on the green triangle in the editor. You need to provide 4 inputs instead.
  1 Kommentar
sanjiv kumar
sanjiv kumar am 13 Okt. 2021
Thank you all, the above suggestion are helpful. I am able to run the code.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by