Not enough input arguments.
6 次查看(过去 30 天)
显示 更早的评论
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;
0 个评论
回答(2 个)
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
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!