
function z=usmodel_fff(y)
z=zeros(40,1);
global ex_ ex_det_ it_ recur_

global calfa cbeta cbetabar ccs ccy cfc cg cgamma cgy chabb 
global cik cikbar cindp cindw cinvs ciy cky clandap clandaw clk 
global cmap cmaw constebeta constelab constepinf conster cpie cprobp cprobw ...
 cr 
global crdpi crdy crhoa crhoas crhob crhog crhols crhoms crhopinf crhoqs 
global crhow crk crkky crpi crr cry csadjcost csigl csigma ctou 
global ctrend curvp curvw cw cwhlc cwly czcap 
usmodel_stst;
z(1) = 0*(1-calfa)*y(1)+1*y(1) -(calfa*y(30)+(1-calfa)*(y(36)));
z(2) = y(40) -((1/(czcap/(1-czcap)))*y(30));
z(3) = y(30) -((y(36))+y(19)-y(15));
z(4) = y(15) -(y(17)+y(40));
z(5) = y(13) -((1/(1+cbetabar*cgamma))*(y(13)+cbetabar*cgamma*y(13)+(1/( ...
cgamma^2*csadjcost))*y(26))+y(27));
z(6) = y(26) -(-y(32)-0*y(2)+(1/((1-chabb/cgamma)/(csigma*(1+chabb/cgamma)) ...
))*y(2)+(crk/(crk+(1-ctou)))*y(30)+((1-ctou)/(crk+(1-ctou)))*y(26));
z(7) = y(4) -((chabb/cgamma)/(1+chabb/cgamma)*y(4)+(1/(1+chabb/cgamma))* ...
y(4)+((csigma-1)*cwhlc/(csigma*(1+chabb/cgamma)))*(y(19)-y(19))-(1-chabb/ ...
cgamma)/(csigma*(1+chabb/cgamma))*(y(32)+0*y(2))+y(2));
z(8) = y(38) -(ccy*y(4)+ciy*y(13)+y(11)+crkky*y(40));
z(9) = y(38) -(cfc*(calfa*y(15)+(1-calfa)*y(19)+y(1)));
z(10) = y(36) -(csigl*y(19)+(1/(1-chabb/cgamma))*y(4)-(chabb/cgamma)/(1- ...
chabb/cgamma)*y(4));
z(11) = y(17) -((1-cikbar)*y(17)+(cikbar)*y(13)+(cikbar)*(cgamma^2* ...
csadjcost)*y(27));
z(12) = y(21) -(calfa*y(29)+(1-calfa)*(y(35))-1*y(1)-0*(1-calfa)*y(1));
z(13) = y(39) -((1/(czcap/(1-czcap)))*y(29));
z(14) = y(29) -(y(35)+y(18)-y(14));
z(15) = y(14) -(y(16)+y(39));
z(16) = y(12) -((1/(1+cbetabar*cgamma))*(y(12)+cbetabar*cgamma*y(12)+(1/( ...
cgamma^2*csadjcost))*y(25))+y(27));
z(17) = y(25) -(-y(28)+y(23)-0*y(2)+(1/((1-chabb/cgamma)/(csigma*(1+chabb/ ...
cgamma))))*y(2)+(crk/(crk+(1-ctou)))*y(29)+((1-ctou)/(crk+(1-ctou)))*y(25));
z(18) = y(3) -((chabb/cgamma)/(1+chabb/cgamma)*y(3)+(1/(1+chabb/cgamma))* ...
y(3)+((csigma-1)*cwhlc/(csigma*(1+chabb/cgamma)))*(y(18)-y(18))-(1-chabb/ ...
cgamma)/(csigma*(1+chabb/cgamma))*(y(28)-y(23)+0*y(2))+y(2));
z(19) = y(37) -(ccy*y(3)+ciy*y(12)+y(11)+1*crkky*y(39));
z(20) = y(37) -(cfc*(calfa*y(14)+(1-calfa)*y(18)+y(1)));
z(21) = y(23) -((1/(1+cbetabar*cgamma*cindp))*(cbetabar*cgamma*y(23)+cindp* ...
y(23)+((1-cprobp)*(1-cbetabar*cgamma*cprobp)/cprobp)/((cfc-1)*curvp+1)*( ...
y(21)))+y(33));
z(22) = y(35) -((1/(1+cbetabar*cgamma))*y(35)+(cbetabar*cgamma/(1+cbetabar* ...
cgamma))*y(35)+(cindw/(1+cbetabar*cgamma))*y(23)-(1+cbetabar*cgamma*cindw)/( ...
1+cbetabar*cgamma)*y(23)+(cbetabar*cgamma)/(1+cbetabar*cgamma)*y(23)+(1- ...
cprobw)*(1-cbetabar*cgamma*cprobw)/((1+cbetabar*cgamma)*cprobw)*(1/((clandaw ...
-1)*curvw+1))*(csigl*y(18)+(1/(1-chabb/cgamma))*y(3)-((chabb/cgamma)/(1- ...
chabb/cgamma))*y(3)-y(35))+1*y(34));
z(23) = y(28) -(crpi*(1-crr)*y(23)+cry*(1-crr)*(y(37)-y(38))+crdy*(y(37)- ...
y(38)-y(37)+y(38))+crr*y(28)+y(22));
z(24) = y(1) -(crhoa*y(1)+ex_(it_-1,1));
z(25) = y(2) -(crhob*y(2)+ex_(it_-1,2));
z(26) = y(11) -(crhog*(y(11))+ex_(it_-1,3)+cgy*ex_(it_-1,1));
z(27) = y(27) -(crhoqs*y(27)+ex_(it_-1,6));
z(28) = y(22) -(crhoms*y(22)+ex_(it_-1,4));
z(29) = y(33) -(crhopinf*y(33)+y(9)-cmap*y(9));
z(30) = y(9) -(ex_(it_-1,5));
z(31) = y(34) -(crhow*y(34)+y(10)-cmaw*y(10));
z(32) = y(10) -(ex_(it_-1,7));
z(33) = y(16) -((1-cikbar)*y(16)+cikbar*y(12)+cikbar*cgamma^2*csadjcost* ...
y(27));
z(34) = y(8) -(y(37)-y(37)+ctrend);
z(35) = y(5) -(y(3)-y(3)+ctrend);
z(36) = y(6) -(y(12)-y(12)+ctrend);
z(37) = y(7) -(y(35)-y(35)+ctrend);
z(38) = y(24) -(1*(y(23))+constepinf);
z(39) = y(31) -(1*(y(28))+conster);
z(40) = y(20) -(y(18)+constelab);
if ~isreal(z)
  z = real(z)+imag(z).^2;
end
