Not enough input arguments.

6 次查看(过去 30 天)
ninu
ninu 2020-5-14
评论: ninu 2020-5-14
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;

回答(2 个)

Rik
Rik 2020-5-14
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 个评论
ninu
ninu 2020-5-14
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.

请先登录,再进行评论。


Star Strider
Star Strider 2020-5-14
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 个评论
ninu
ninu 2020-5-14
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by