(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 14012, 481]*) (*NotebookOutlinePosition[ 14921, 513]*) (* CellTagsIndexPosition[ 14877, 509]*) (*WindowFrame->Normal*) Notebook[{ Cell["(* Nov. 4, 1998 RBC's 1 *)", "Input", PageWidth->Infinity], Cell["\<\ (* The utility function. *) u[c_,l_]=(c^(1-gam))/(1-gam)+b(l^(1-ngam))/(1-ngam);\ \>", "Input", PageWidth->Infinity], Cell[TextData["(* The production function. *)"], "Input", PageWidth->Infinity], Cell["F[k_,n_,a_]:=a k^alpha n^(1-alpha);", "Input", PageWidth->Infinity], Cell[TextData[ "(* There are two FOCs. \n\tu'(c) = B E[u'(c(t+1)(F'+1-del)]\n\tu sub l/u \ sub c = F sub n\n*)"], "Input", PageWidth->Infinity], Cell[TextData["(* Finding the Steady state solution. *)"], "Input", PageWidth->Infinity], Cell[TextData["\n(* Specs *)"], "Input", PageWidth->Infinity, FontFamily->"Courier New", FontSize->12, FontWeight->"Bold", FontColor->GrayLevel[0], Background->GrayLevel[1]], Cell["\<\ beta=.96;gam=1.5;ngam=1.5;b=2;\t\t(* Preferences *) delta=.08;alpha=.25;gam=1.5;ngam=1.5;b=2; rho=0.95;\t\t\t\t\t\t\t(*Production*)\ \>", "Input", PageWidth->Infinity, FontFamily->"Courier New", FontSize->12, FontWeight->"Bold", FontColor->GrayLevel[0], Background->GrayLevel[1]], Cell[CellGroupData[{ Cell[BoxData[ \(mrs[c_, leis_] = \((D[u[c, leis], leis])\)/D[u[c, leis], c]\)], "Input"], Cell[BoxData[ \(\(2.`\ c\^1.5`\)\/leis\^1.5`\)], "Output"] }, Open ]], Cell["\<\ \t\t\t\t\t (* The 2 FOC's and Feasibility: *) s1:={beta(D[F[k,n,a],k]+1-delta)==1}/.{a->1}; s2:={mrs[c,leis]==D[F[k,n,a],n]/.{leis->(1-n)}}; s3:={F[k,n,1]==c + delta k}; s0=Join[s1,s2,s3];\ \>", "Input", PageWidth->Infinity, FontFamily->"Courier New", FontSize->12, FontWeight->"Bold", FontColor->GrayLevel[0], Background->GrayLevel[1]], Cell[BoxData[ \( (*In\ case\ you\ want\ to\ know\ what\ s0\ looks\ \(like : \)*) \)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(s0\)], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ StyleBox["0.959999999999999964`", StyleBoxAutoDelete->True, PrintPrecision->2], " ", RowBox[{"(", RowBox[{\(0.920000000000000106`\[InvisibleSpace]\), "+", FractionBox[ RowBox[{ StyleBox["0.25`", StyleBoxAutoDelete->True, PrintPrecision->2], " ", \(n\^0.75`\)}], \(k\^0.75`\)]}], ")"}]}], "==", "1"}], ",", RowBox[{\(\(2.`\ c\^1.5`\)\/\((1 - n)\)\^1.5`\), "==", FractionBox[ RowBox[{"0.75`", " ", "a", " ", SuperscriptBox["k", StyleBox["0.25`", StyleBoxAutoDelete->True, PrintPrecision->2]]}], \(n\^0.25`\)]}], ",", RowBox[{ RowBox[{ SuperscriptBox["k", StyleBox["0.25`", StyleBoxAutoDelete->True, PrintPrecision->2]], " ", \(n\^0.75`\)}], "==", RowBox[{"c", "+", RowBox[{ StyleBox["0.08`", StyleBoxAutoDelete->True, PrintPrecision->1], " ", "k"}]}]}]}], "}"}]], "Output"] }, Open ]], Cell[BoxData[ \( (*\ Temporarily\ set\ the\ parameter\ a\ to\ its\ steady\ state\ \(value : \)*) \)], "Input"], Cell[BoxData[ \(\(s0a = s0 /. {a -> 1}; \)\)], "Input"], Cell[CellGroupData[{ Cell["\<\ (* Getting the steady state state solution. \tNote that an initial guess is needed. *) Timing[sol1=FindRoot[s0a,{c,.3},{k,1},{n,.3}]]\ \>", "Input", PageWidth->Infinity, FontFamily->"Courier New", FontSize->12, FontWeight->"Bold", FontColor->GrayLevel[0], Background->GrayLevel[1]], Cell[BoxData[ \({0.0600000000000004973`\ Second, {c \[Rule] 0.387607847120771875`, k \[Rule] 0.953134050296599966`, n \[Rule] 0.364862687636910099`}}\)], "Output"] }, Open ]], Cell[TextData["(* Setting the steady state values. *)"], "Input", PageWidth->Infinity, FontFamily->"Courier New", FontSize->12, FontWeight->"Bold", FontColor->GrayLevel[0], Background->GrayLevel[1]], Cell["\<\ cbar=c/.sol1; kbar=k/.sol1; nbar=n/.sol1; abar=1;\ \>", "Input", PageWidth->Infinity, FontFamily->"Courier New", FontSize->12, FontWeight->"Bold", FontColor->GrayLevel[0], Background->GrayLevel[1]], Cell["\<\ (* Now we begin to set up the system to solve for the \tRBC system. We will have initially 4 equations. \tThese will be of the form \t\tm1 = {f1==f2} \t\tm2 = {f3==f4} \t\tm3 = {f5==f6} \t\tm4 = {f7==f8} \tm1 and m2 are the FOC's. \tm3 is K(t+1) = K(t)(1-del) +I(t) and m4 is Y(t) = F(k,n,a) = C(t) + I(t) Later we can add complications, like taxes, government spending, a foreign sector, more goods and capital types. *)\ \>", "Input", PageWidth->Infinity], Cell[BoxData[ \(u[c_, l_]\)], "Input"], Cell[BoxData[""], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(\(f1 = \(D[mrs[c, leis], c]\ dc + D[mrs[c, leis], leis]\ dleis /. \n \t\t{dc -> c1\ \ c, dleis -> \(-n1\)\ n, leis -> \((1 - n)\)}\) /. { c -> cbar, n -> nbar}\n\)\)], "Input"], Cell[BoxData[ \(1.43023912892051852`\ c1 + 0.821619014319681362`\ n1\)], "Output"] }, Open ]], Cell[BoxData[ \(\(FN[k_, n_, a_] := D[F[k, n, a], n]; \)\)], "Input"], Cell[CellGroupData[{ Cell["\<\ f2= D[FN[k,n,a],k] dk+D[FN[k,n,a],n] dn+D[FN[k,n,a],a] da/. {dk->k1 k,dn->n1 n,da->a1 a}/.{k->kbar,n->nbar,a->1}\ \>", "Input", PageWidth->Infinity], Cell[BoxData[ \(0.953492752606637772`\ a1 + 0.238373188151659443`\ k1 - 0.238373188151659443`\ n1\)], "Output"] }, Open ]], Cell[BoxData[ \(\(uc[c_, leis_] := D[u[c, leis], c]; \)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(\(f3 = \(D[uc[c, leis], c] dc\ + D[uc[c, leis], leis]\ dleis /. \n \t\t{dc -> c1\ c, dleis -> \(-n1\)\ n, leis -> \((1 - n)\)}\) /. { c -> cbar, \n\t\t\tn -> nbar}\n\)\)], "Input"], Cell[BoxData[ \(\(-6.21587708406745864`\)\ c1\)], "Output"] }, Open ]], Cell[BoxData[ \(FK[k_, n_, a_] := D[F[k, n, a], k]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(f4 = Simplify[\(beta \((uc[c, leis])\)* \((D[FK[k, n, a], k] dk + D[FK[k, n, a], n] dn + D[FK[k, n, a], a] da)\) + \n\t\t\t\t\n beta \((D[uc[c, leis], c] dc\ + D[uc[c, leis], leis]\ dleis)\)* \n\t\t\t\((FK[k, n, a] - delta)\) /. \n \t\t\t{dc -> c2\ c, dleis -> \(-n2\)\ n, dk -> k2\ k, da -> a2\ a, dn -> n2\ n, leis -> \((1 - n)\)}\) /. {c -> cbar, \n\t\t\tn -> nbar, k -> kbar, a -> 1}]\)], "Input"], Cell[BoxData[ \(0.484009628946211822`\ a2 - 0.248635083362936892`\ c2 - 0.3630072217096588`\ k2 + 0.3630072217096588`\ n2\)], "Output"] }, Open ]], Cell["\<\ f5:=k2; f6:=k1(1-delta)+delta i1;\ \>", "Input", PageWidth->Infinity], Cell["\<\ f7:=(D[f,k]dk k1+D[f,n]dn +D[f,a]da )/. {dk->k1 k,dn->n1 n,da->a1 a}/. \t{k->kbar,n->nbar,a->1};\ \>", "Input", PageWidth->Infinity], Cell["f8:=(cbar c1+delta kbar i1);", "Input", PageWidth->Infinity], Cell[TextData["Clear[m1,m2,m3,m4]"], "Input", PageWidth->Infinity], Cell["\<\ m1:={f1==f2}/.{a->1}; m2:={f3==f4}/.{a->1}; m3:={f5==f6}; m4:={f7==f8}/.{a->1};\ \>", "Input", PageWidth->Infinity, FontFamily->"Courier New", FontSize->12, FontWeight->"Bold", FontColor->GrayLevel[0], Background->GrayLevel[1]], Cell[BoxData[{ \(m1 := {f1 == f2}\), \(m2 := {f3 == f4} /. {a -> 1}; \nm3 := {f5 == f6}; \n m4 := {f7 == f8} /. {a -> 1}; \)}], "Input"], Cell[TextData[ "(* Setting the percent variation variables. \nEach variable is the \ percentage deviation from the \nsteady state value. This applies to c1, k1, \ n1, i1, \nand a1 The bij's are coefficients that we seek.*)"], "Input", PageWidth->Infinity], Cell["\<\ c1:=b11 k1 + b12 a1; n1:=b21 k1 + b22 a1; i1:=b31 k1 + b32 a1; k2:=b41 k1 + b42 a1; (* And for next period (period t+1) *) c2:=b11 k2 + b12 a2; n2:=b21 k2 + b22 a2; a2:=rho a1;\ \>", "Input", PageWidth->Infinity], Cell["\<\ (* Pack the four mi's into one: *) m0=Join[m1,m2,m3,m4]; \ \>", "Input", PageWidth->Infinity], Cell[TextData[ "(* There are 8 eq'ns and 8 unknowns. \nEach of the mi's is 2 eq'ns. Each is \ of the form\n\t\t\t\t(AAA) k1 +(BBB) a1 ==(CCC)k1 + (DDD)a1\n\nThis is solved \ by the \"Method of undetermined \ncoefficients\", which is done next.\nThe \ method of undetermined coefficients is a fancy term\nfor the idea that (AAA) \ gets set equal to (CCC),\nand (BBB) to (DDD).\n*)"], "Input", PageWidth->Infinity], Cell[CellGroupData[{ Cell[BoxData[ \(m0\)], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ \(1.43023912892051852`\ \((a1\ b12 + b11\ k1)\) + 0.821619014319681362`\ \((a1\ b22 + b21\ k1)\) == 0.953492752606637772`\ a1 + 0.238373188151659443`\ k1 - 0.238373188151659443`\ \((a1\ b22 + b21\ k1)\)\), ",", RowBox[{ \(\(-6.21587708406745864`\)\ \((a1\ b12 + b11\ k1)\)\), "==", RowBox[{ \(0.459809147498901182`\ a1\), "-", \(0.3630072217096588`\ \((a1\ b42 + b41\ k1)\)\), "-", RowBox[{"0.248635083362936892`", " ", RowBox[{"(", RowBox[{ RowBox[{ StyleBox["0.95`", StyleBoxAutoDelete->True, PrintPrecision->2], " ", "a1", " ", "b12"}], "+", \(b11\ \((a1\ b42 + b41\ k1)\)\)}], ")"}]}], "+", RowBox[{"0.3630072217096588`", " ", RowBox[{"(", RowBox[{ RowBox[{ StyleBox["0.95`", StyleBoxAutoDelete->True, PrintPrecision->2], " ", "a1", " ", "b22"}], "+", \(b21\ \((a1\ b42 + b41\ k1)\)\)}], ")"}]}]}]}], ",", RowBox[{\(a1\ b42 + b41\ k1\), "==", RowBox[{\(0.920000000000000106`\ k1\), "+", RowBox[{ StyleBox["0.08`", StyleBoxAutoDelete->True, PrintPrecision->1], " ", \((a1\ b32 + b31\ k1)\)}]}]}], ",", \(0 == 0.387607847120771875`\ \((a1\ b12 + b11\ k1)\) + 0.0762507240237280026`\ \((a1\ b32 + b31\ k1)\)\)}], "}"}]], "Output"] }, Open ]], Cell["\<\ z1=Simplify[m0/.{a1->1,k1->0}]; z2=Simplify[m0/.{a1->0,k1->1}]; (* You have just created 8 eq'ns \t\t\tin the 8 unknown bij's.*)\ \>", "Input", PageWidth->Infinity], Cell[TextData["(* These are: *)"], "Input", PageWidth->Infinity], Cell["\<\ (*Put them together: *) z0=Join[z1,z2];\ \>", "Input", PageWidth->Infinity, FontFamily->"Courier New", FontSize->12, FontWeight->"Bold", FontColor->GrayLevel[0], Background->GrayLevel[1]], Cell[CellGroupData[{ Cell["\<\ (* Check that we have 8 equations: *) Length[z0]\ \>", "Input", PageWidth->Infinity], Cell[BoxData[ \(8\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\n (*\ Now\ solve\ the\ \(system.\)\ *) \n Timing[sol2 = FindRoot[z0, \n{b11, .2}, {b12, .2}, \n{b21, \(-.1\)}, {b22, .2}, \n{b31, .2}, {b32, .2}, \n{b41, .2}, {b42, .2}]]\n\)\)], "Input"], Cell[BoxData[ \({0.109999999999999431`\ Second, {b11 \[Rule] 0.0456979657131240379`, b12 \[Rule] \(-0.136467223210945265`\), b21 \[Rule] 0.163222115288493396`, b22 \[Rule] 1.08366223108053393`, b31 \[Rule] \(-0.232297992375139861`\), b32 \[Rule] 0.693708384655915022`, b41 \[Rule] 0.901416160609988814`, b42 \[Rule] 0.0554966707724732`}}\)], "Output"] }, Open ]], Cell[TextData[ "(*This gives us the answers to the sytem.\n\nThe consumption function is of \ the form\n\t\tc_hat(t) = 0.34 k_hat(t) + 0.82 a_hat(t)\n\nwhere the x_hat(t) \ means the date t percentage \ndeviation of x away from the steady state x.\n\n\ Notice a few things:\n\tA) Higher capital (k1) causes \t\n\t\t1) Higher \ consumption \t(b11>0)\n\t\t2) Lower labor input\t(b21<0)\n\t\t3) Lower \ investment\t\t(b31<0)\n\t\t4) Higher K(t+1)\t\t(b41>0)\n\tB) Higher current \ technology (a1) causes\n\t\t1) Higher consumption \t(b12>0)\n\t\t2) Lower \ labor input \t(b22<0)\n\t\t3) Higher investment\t(b31>0)\n\t\t4) Hihger \ K(t+1)\t\t(b41>0)\n"], "Input", PageWidth->Infinity] }, FrontEndVersion->"Microsoft Windows 3.0", ScreenRectangle->{{0, 640}, {0, 424}}, WindowToolbars->{}, CellGrouping->Manual, WindowSize->{496, 316}, WindowMargins->{{20, Automatic}, {16, Automatic}}, PrintingCopies->1, PrintingPageRange->{5, 7}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False} ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1709, 49, 66, 1, 22, "Input"], Cell[1778, 52, 128, 4, 32, "Input"], Cell[1909, 58, 80, 1, 22, "Input"], Cell[1992, 61, 75, 1, 22, "Input"], Cell[2070, 64, 146, 3, 55, "Input"], Cell[2219, 69, 90, 1, 22, "Input"], Cell[2312, 72, 185, 6, 55, "Input"], Cell[2500, 80, 302, 10, 69, "Input"], Cell[CellGroupData[{ Cell[2827, 94, 92, 1, 22, "Input"], Cell[2922, 97, 62, 1, 32, "Output"] }, Open ]], Cell[2999, 101, 359, 14, 127, "Input"], Cell[3361, 117, 101, 2, 22, "Input"], Cell[CellGroupData[{ Cell[3487, 123, 35, 1, 22, "Input"], Cell[3525, 126, 1288, 33, 33, "Output"] }, Open ]], Cell[4828, 162, 130, 3, 22, "Input"], Cell[4961, 167, 59, 1, 22, "Input"], Cell[CellGroupData[{ Cell[5045, 172, 304, 11, 84, "Input"], Cell[5352, 185, 179, 3, 22, "Output"] }, Open ]], Cell[5546, 191, 210, 6, 40, "Input"], Cell[5759, 199, 219, 11, 84, "Input"], Cell[5981, 212, 476, 18, 192, "Input"], Cell[6460, 232, 42, 1, 22, "Input"], Cell[6505, 235, 26, 0, 22, "Input"], Cell[CellGroupData[{ Cell[6556, 239, 223, 4, 48, "Input"], Cell[6782, 245, 86, 1, 22, "Output"] }, Open ]], Cell[6883, 249, 73, 1, 22, "Input"], Cell[CellGroupData[{ Cell[6981, 254, 160, 4, 32, "Input"], Cell[7144, 260, 122, 2, 22, "Output"] }, Open ]], Cell[7281, 265, 72, 1, 22, "Input"], Cell[CellGroupData[{ Cell[7378, 270, 228, 4, 61, "Input"], Cell[7609, 276, 63, 1, 22, "Output"] }, Open ]], Cell[7687, 280, 67, 1, 22, "Input"], Cell[CellGroupData[{ Cell[7779, 285, 536, 9, 112, "Input"], Cell[8318, 296, 146, 2, 22, "Output"] }, Open ]], Cell[8479, 301, 82, 4, 32, "Input"], Cell[8564, 307, 144, 5, 44, "Input"], Cell[8711, 314, 68, 1, 22, "Input"], Cell[8782, 317, 68, 1, 22, "Input"], Cell[8853, 320, 249, 11, 84, "Input"], Cell[9105, 333, 149, 3, 61, "Input"], Cell[9257, 338, 259, 4, 55, "Input"], Cell[9519, 344, 225, 10, 101, "Input"], Cell[9747, 356, 107, 7, 66, "Input"], Cell[9857, 365, 414, 6, 123, "Input"], Cell[CellGroupData[{ Cell[10296, 375, 35, 1, 22, "Input"], Cell[10334, 378, 1668, 36, 81, "Output"] }, Open ]], Cell[12017, 417, 177, 6, 55, "Input"], Cell[12197, 425, 66, 1, 22, "Input"], Cell[12266, 428, 210, 10, 69, "Input"], Cell[CellGroupData[{ Cell[12501, 442, 96, 4, 32, "Input"], Cell[12600, 448, 35, 1, 22, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[12672, 454, 234, 4, 170, "Input"], Cell[12909, 460, 400, 6, 67, "Output"] }, Open ]], Cell[13324, 469, 684, 10, 372, "Input"] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)