nvar=12; @--Order things with the predetermined variables first x[1] = capital1 x[2] = capital2 x[3] = bonds1 x[4] = shock1 x[5] = shock2 x[6] = labor1 x[7] = labor2 x[8] = cons1 x[9] = cons2 x[10] = Q x[11] = inv1 x[12] = inv2 @ x0=zeros(nvar,1); x0[1] = 14; x0[2] = 14; x0[3] = 0; x0[4] = 0; x0[5] = 0; x0[6] = 0.33; x0[7] = 0.33; x0[8] = 0.4; x0[9] = 0.4; x0[10] = 0.99; x0[11] = 0.3; x0[12] = 0.3; fn r1(x) = alpha*exp(x[4])*x[1]^(alpha-1)*x[6]^(1-alpha); fn r2(x) = alpha*exp(x[5])*x[2]^(alpha-1)*x[7]^(1-alpha); fn w1(x) = (1-alpha)*exp(x[4])*x[1]^alpha*x[6]^(-alpha); fn w2(x) = (1-alpha)*exp(x[5])*x[2]^alpha*x[7]^(-alpha); fn f1(x) = exp(x[4])*x[1]^alpha*x[6]^(1-alpha); fn f2(x) = exp(x[5])*x[2]^alpha*x[7]^(1-alpha); fn muc1(x)= 1/x[8]; fn muc2(x)= 1/x[9]; fn mun1(x)=-chi/(1-x[6]); fn mun2(x)=-chi/(1-x[7]); fn phi1(x)=delta - (delta/gama) + (1/(gama*delta^(gama-1)))*(x[11]/x[1])^gama; fn phi2(x)=delta - (delta/gama) + (1/(gama*delta^(gama-1)))*(x[12]/x[2])^gama; fn phip1(x)=(1/(delta^(gama-1)))*(x[11]/x[1])^(gama-1); fn phip2(x)=(1/(delta^(gama-1)))*(x[12]/x[2])^(gama-1); @--Define the left and right hand sides of the First Order Conditions--@ fn lhs1(x)=x[1]; fn rhs1(x)=(1-delta)*x[1]+phi1(x)*x[1]; fn lhs2(x)=x[2]; fn rhs2(x)=(1-delta)*x[2]+phi2(x)*x[2]; fn lhs3(x)=x[3]; fn rhs3(x)=(r1(x)*x[1]+w1(x)*x[6]+x[3]-x[8]-x[11])/x[10]; fn lhs4(x)=x[4]; fn rhs4(x)=am11*x[4]+am12*x[5]; fn lhs5(x)=x[5]; fn rhs5(x)=am21*x[4]+am22*x[5]; fn lhs6(x)=beta*muc1(x)*(r1(x) + (1/phip1(x))*(1-delta+phi1(x)-phip1(x)*(x[11]/x[1]))); fn rhs6(x)=muc1(x)/phip1(x); fn lhs7(x)=beta*muc2(x)*(r2(x) + (1/phip2(x))*(1-delta+phi2(x)-phip2(x)*(x[12]/x[2]))); fn rhs7(x)=muc2(x)/phip2(x); fn lhs8(x)=beta*muc1(x); fn rhs8(x)=muc1(x)*x[10]+2*psi*x[3]; fn lhs9(x)=beta*muc2(x); fn rhs9(x)=muc2(x)*x[10]-2*psi*x[3]; fn lhs10(x)=0; fn rhs10(x)=muc1(x)*w1(x)+mun1(x); fn lhs11(x)=0; fn rhs11(x)=muc2(x)*w2(x)+mun2(x); fn lhs12(x)=0; fn rhs12(x)=f1(x)+f2(x)-x[8]-x[9]-x[11]-x[12]; proc sse(x); local e; e = zeros(nvar,1); e[1] = lhs1(x)-rhs1(x); e[2] = lhs2(x)-rhs2(x); e[3] = lhs3(x)-rhs3(x); e[4] = lhs4(x)-rhs4(x); e[5] = lhs5(x)-rhs5(x); e[6] = lhs6(x)-rhs6(x); e[7] = lhs7(x)-rhs7(x); e[8] = lhs8(x)-rhs8(x); e[9] = lhs9(x)-rhs9(x); e[10] = lhs10(x)-rhs10(x); e[11] = lhs11(x)-rhs11(x); e[12] = lhs12(x)-rhs12(x); retp(e); endp; @sse(x0)';@ {nlc, nlo}=nlsys(nlc, &sse, x0); xsol = nlo.xp; save path = c:\teaching xsol; xbar=xsol; print "STEADY STATE VECTOR"; xbar'; print "##################";