% defaults and premia;

var y,x,c;

varexo e_x;

parameters std_x,rho,alpha,beta,gamma,fwd;

alpha=0.5;
beta=-1;
gamma=-0.6;
std_x=0.01;
rho=.2;
fwd=0;


model;
y=alpha*y(-1)+beta*y(-1)^2+gamma*y(-1)^3+y(-1)^2*c(-1)+c(-1)^2*x(-1)+e_x^3+y(-1)*(x(-1))^2+x;
x=rho*x(-1)+e_x;
c=alpha*c(+1)+fwd*y(+1)+x;
end;

shocks;
var e_x=std_x^2;
end;

initval;
y=0;
x=0;
c=0;
end;
steady(nocheck);

options_.k_order_solver=3;
optiond_.pruning=0;
options_.periods=5000;
options_.drop=100;

stoch_simul(order=3) y,x;

bins=length(oo_.endo_simul(1,:))/200;
nm='y';figure;hist(exp(oo_.endo_simul(find_incell(M_.endo_names,nm),:)),bins);
h = findobj(gca,'Type','patch');
set(h,'FaceColor','r','EdgeColor','w','facealpha',0.75)
nm='\<x\>';hold;hist(exp(oo_.endo_simul(find_incell(M_.endo_names,nm),:)),bins);
h = findobj(gca,'Type','patch');
set(h,'facealpha',0.75)
