Is it wrong to put 'end' after certain sections, or does the problem lie in other codes?
Show older comments
I know it is required to put 'end' after certain lines, so if an error pops out, something must be wrong with my other codes. But I can't figure our what is wrong. Can anyone help? Thank you very much!
var h hm hf x yf yfi yff ym y theta;
varexo eps_x,
parameters rho_x alpha delta STDERR_x;
delta=2;
alpha=0.4;
STDERR_x=0.5;
rho_x=0.95;
model;
h=hm+hf;
hf=x*h;
hm=(1-x)*h;
yf=(hf)^(1/delta);
yfi=theta*yf;
yff=(1-theta)*yf;
theta=hm;
ym=(yfi)^alpha*(hm)^(2-alpha);
y=(1-theta)*yf+ym;
x=rho_x*x(-1)+eps_x;
end;
initval;
h=0;
hf=0;
hm=0;
yf=0;
yfi=0;
yff=0;
theta=0;
ym=0;
y=0;
x=0;
end;
steady;
check;
shocks;
var eps_x; stderr STDERR_x;
end;
stoch_simul(dr_algo=0,order=1,irf=60) y ym yf yff yfi hm hf;

2 Comments
Walter Roberson
on 17 Aug 2021
This is specific to the third party dynare product.
Jo Ann Tan
on 17 Aug 2021
Accepted Answer
More Answers (1)
Image Analyst
on 17 Aug 2021
0 votes
You can't just go dropping "end" statements wherever you want. You put them after
- an "if" statement or
- a "while" statement
- a "switch" statement
- a "function" statement (except in a GUIDE .fig file).
to close or finish off that block of code. You can't just put them anywhere at random hoping it will help, or at least be harmless. It doesn't work that way. In the code you posted, you put the end statements in places where it just doesn't make sense since it's not closing off one of those cases I listed above.
3 Comments
Walter Roberson
on 17 Aug 2021
This is matlab code intended to be preprocessed by the third party product Dynare
Image Analyst
on 17 Aug 2021
Never heard of it, and she didn't mention it. She just shows a very badly-named file called "try.m"
But you are probably right. And there you go again, showing off with your Mind Reading Toolbox. 😄 I need a copy of that.
Walter Roberson
on 17 Aug 2021
just had to search for varexo...
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!