Not enough input arguments.

5 Ansichten (letzte 30 Tage)
ninu
ninu am 14 Mai 2020
Kommentiert: ninu am 14 Mai 2020
Dear all,
Can you please advise me how I can find a solution for this error? I'am traying to run DSGE model
XXKHB
Not enough input arguments.
Error in XXKHB (line 5)
lHsHc = omega1*(AH/AG*(1-x))^(1/(1-eps+bet));
and all code:
function Y=XXKHB(x)
% discrete model
% implicit equation for leisure x - new version (KHB model)
global omega1 omega2 omega3 omega4 Omega omeg AH AG AF alpha bet eps gamma tau_L tau_K theta deltaK deltaH rho rhod sigma eta lambda r_p
lHsHc = omega1*(AH/AG*(1-x))^(1/(1-eps+bet));
lGsGc = bet/(1-bet)*(1-eps)/eps*lHsHc;
rhat = Omega*AG^omeg*AH^(1-omeg)*(1-x)^(1-omeg);
g = ((1+rhat-deltaK)/(1+rhod))^(1/theta)-1;
what = bet*AG/lGsGc^(1-bet);
pi = (1+sigma)/(1+g)-1;
Rhat = (1+rhat-deltaK)*(1+pi)-1;
lH = (g+deltaH)/AH*lHsHc^(1-eps);
a = 1-(gamma*Rhat/what*AF^(1/gamma))^(gamma/(1-gamma));
F = ((1-a)/AF)^(1/gamma);
c_h = what/(1+what*F+Rhat*a)*x/alpha;
apG = AG*lGsGc^bet;
h_k = (apG-g-deltaK)/(c_h+apG/lHsHc*lH);
c_k = c_h*h_k;
sG = (g+deltaK+c_k)/apG;
lF = F*c_h;
lG = 1-x-lF-lH;
Y = sG/lG-h_k/lGsGc;

Antworten (2)

Rik
Rik am 14 Mai 2020
I'm going to ignore the decision to use global variables (especially so many, and with such short names).
You ran the function without any inputs. This is a function that requires input.
>> XXKHB
%error
>> Y=XXKHB(x);
%should run as expected
  1 Kommentar
ninu
ninu am 14 Mai 2020
Thank you for the answer, I have this code from model paper's authors and it was written 10 years ago.
I tried to run it but I have many errors and this is one of them.

Melden Sie sich an, um zu kommentieren.


Star Strider
Star Strider am 14 Mai 2020
It appears that some of the variables necessary for the ‘lHsHc’ calculationwere not passed to the ‘XXKHB’ function. They may not exist as global variables in whatever workspace they were supposed to be defined.
This is but one example to illustrate that using global variables is never a good idea.
Instead do something like this:
function Y=XXKHB(x, omega1, omega2, omega3, omega4, Omega, omeg, AH, AG, AF, alpha, bet, eps, gamma, tau_L, tau_K, theta, deltaK, deltaH, rho, rhod, sigma, eta, lambda, r_p)
then pass all the appropriate arguments to the function when you call it. Any that are not defined will immediatley throw the appropriate errors.
  1 Kommentar
ninu
ninu am 14 Mai 2020
Thank you for the answer, I have this code from model paper's authors and it was written 10 years ago.
I tried to run it but I have many errors and this is one of them.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by