use Wolfram Mathematica to write the economic essay
(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 12.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 10539, 248] NotebookOptionsPosition[ 9903, 228] NotebookOutlinePosition[ 10240, 243] CellTagsIndexPosition[ 10197, 240] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"(*", RowBox[{ RowBox[{ "Calculate", " ", "economic", " ", "indicators", " ", "depicting", " ", "long", " ", "term", " ", "trends"}], " ", "-", " ", RowBox[{ "an", " ", "example", " ", "with", " ", "quarterly", " ", "data"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{ "First", " ", "I", " ", "downloaded", " ", "data", " ", "on", " ", "my", " ", "Mac"}], ",", " ", RowBox[{"from", " ", "FRED"}]}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"ClearAll", ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Remove", " ", "[", "\"\<Global`*\>\"", "]"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "This", " ", "is", " ", "how", " ", "imported", " ", "data", " ", "in", " ", "cvs", " ", "format", " ", "look", " ", RowBox[{"like", ":"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"rawydata", "=", RowBox[{ "Import", "[", "\"\</Users/nmathieu/Downloads/GDP.csv\>\"", "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "You", " ", "need", " ", "to", " ", "eliminate", " ", "the", " ", "inside", " ", "brackets", " ", RowBox[{"(", RowBox[{"list", " ", "in", " ", "the", " ", "list"}], ")"}], " ", "with", " ", "Flatten"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ydata", "=", RowBox[{ RowBox[{ "Import", "[", "\"\</Users/nmathieu/Downloads/GDP.csv\>\"", "]"}], "//", "Flatten"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"cdata", "=", RowBox[{ RowBox[{ "Import", "[", "\"\</Users/nmathieu/Downloads/PCEC.csv\>\"", "]"}], "//", "Flatten"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"eliminate", " ", "the", " ", "dates"}], ",", " ", RowBox[{ "keep", " ", "every", " ", "second", " ", "element", " ", "in", " ", "the", " ", "lists"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"yonly", "=", RowBox[{"Last", "/@", RowBox[{"Partition", "[", RowBox[{"ydata", ",", "2"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"conly", "=", RowBox[{"Last", "/@", RowBox[{"Partition", "[", RowBox[{"cdata", ",", "2"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"calculate", " ", "the", " ", RowBox[{"consumption", "/", "output"}], " ", "each", " ", "quarter"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ratiocyq", "=", RowBox[{"conly", "/", "yonly"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "eliminate", " ", "the", " ", "first", " ", "element", " ", "of", " ", "the", " ", "list", " ", "before", " ", "caculating", " ", "the", " ", "average", " ", "consumption", " ", "output", " ", "ratio", " ", "for", " ", "the", " ", "whole", " ", "period"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"cyq", "=", RowBox[{"Delete", "[", RowBox[{"ratiocyq", ",", "1"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Print", "[", "\"\<C/Y for the period 1947-2019:\>\"", "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Mean", "[", "cyq", "]"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"other", " ", "useful", " ", RowBox[{"manipulations", ":", " ", RowBox[{ "eliminate", " ", "parts", " ", "of", " ", "the", " ", "elements", " ", "of", " ", "a", " ", "list"}]}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"for", " ", RowBox[{"ex", ":", " ", RowBox[{ "eliminate", " ", "the", " ", "first", " ", "10", " ", "years"}]}]}], ",", " ", RowBox[{ "that", " ", "is", " ", "the", " ", "first", " ", "40", " ", "elements", " ", "because", " ", "I", " ", "want", " ", "the", " ", "period", " ", "to", " ", "start", " ", "1957", " ", "instead", " ", "of", " ", "1947"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ "Print", "[", "\"\<C quarterly for the period 1957-2019:\>\"", "]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Drop", "[", RowBox[{"conly", ",", "41"}], "]"}], ";", RowBox[{"(*", RowBox[{ "I", " ", "added", " ", "one", " ", "because", " ", "the", " ", "first", " ", "term", " ", "is", " ", "a", " ", "word", " ", "that", " ", "needs", " ", "to", " ", "be", " ", "eliminated", " ", "too"}], "*)"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"for", " ", RowBox[{"ex", ":", " ", RowBox[{"the", " ", "last", " ", "10", " ", "years"}]}]}], ",", " ", RowBox[{ "that", " ", "is", " ", "the", " ", "las", " ", "40", " ", "elements", " ", "because", " ", "I", " ", "want", " ", "the", " ", "period", " ", "to", " ", "start", " ", "1957", " ", "instead", " ", "of", " ", "1947"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{ "Print", "[", "\"\<Y quarterly for the period 1947-2009:\>\"", "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Drop", "[", RowBox[{"yonly", ",", RowBox[{"-", "40"}]}], "]"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]"}]}]], "Input", CellChangeTimes->{{3.789414040528288*^9, 3.789414288888193*^9}, { 3.7900201349036913`*^9, 3.7900201504200172`*^9}, {3.790020380010124*^9, 3.7900203807940493`*^9}, {3.790020414622364*^9, 3.790020541126563*^9}, { 3.790020718464375*^9, 3.790020794748599*^9}, {3.790020864035513*^9, 3.7900208901640673`*^9}, {3.790021005078186*^9, 3.790021108427026*^9}, { 3.7900213241266212`*^9, 3.7900214024095*^9}, {3.790021526605946*^9, 3.790021633542076*^9}, {3.7900234820523777`*^9, 3.7900234871848927`*^9}, { 3.79002374244658*^9, 3.790023769289939*^9}, {3.79002380977787*^9, 3.7900238238665123`*^9}, {3.790023960495116*^9, 3.7900240004227858`*^9}, { 3.7900240821187*^9, 3.790024088608788*^9}, {3.790024137783252*^9, 3.7900241734962797`*^9}, {3.79002440750764*^9, 3.790024488322109*^9}, 3.790024604102325*^9, {3.790024912104377*^9, 3.790024973996162*^9}, { 3.790025005287833*^9, 3.790025021125103*^9}, {3.7900251156075983`*^9, 3.790025189931978*^9}, {3.790025243955394*^9, 3.79002528251155*^9}, 3.790025324444734*^9, {3.7900255063491297`*^9, 3.790025544294271*^9}, { 3.790025626805093*^9, 3.7900256291193323`*^9}, {3.7900257123460827`*^9, 3.7900257168609343`*^9}, {3.79002575435981*^9, 3.7900257669619226`*^9}, { 3.790025800205867*^9, 3.790025801802842*^9}, {3.790025839855112*^9, 3.790025977777979*^9}, {3.790026086959691*^9, 3.790026089224833*^9}, { 3.790026246808292*^9, 3.790026298356697*^9}, {3.790026396882894*^9, 3.7900264071097116`*^9}, {3.790026459202075*^9, 3.790026552332365*^9}, { 3.7900265903554583`*^9, 3.7900266136098337`*^9}, {3.79002668050285*^9, 3.7900266951833687`*^9}, {3.7900267285400667`*^9, 3.7900268462378674`*^9}, {3.790026884448247*^9, 3.7900271755645638`*^9}, { 3.7900272103539667`*^9, 3.790027312345327*^9}, {3.7900273553504753`*^9, 3.7900273906034307`*^9}, {3.790027609958256*^9, 3.790027664558758*^9}, { 3.790027794127428*^9, 3.790027945411756*^9}, {3.7900279811166887`*^9, 3.790028008496923*^9}, {3.790028089529285*^9, 3.7900283107449427`*^9}, { 3.790028344666679*^9, 3.790028379729891*^9}, {3.790028688370392*^9, 3.790028696403879*^9}}, CellLabel-> "In[3682]:=",ExpressionUUID->"205ec875-2237-47bd-840a-8d8150907d3f"], Cell[CellGroupData[{ Cell[BoxData["\<\"C/Y for the period 1947-2019:\"\>"], "Print", CellChangeTimes->{ 3.7900272412197657`*^9, {3.7900272784199877`*^9, 3.790027296418367*^9}, { 3.790027817338188*^9, 3.790027832346726*^9}, {3.7900278632554197`*^9, 3.790027963799673*^9}, 3.790028280289846*^9, 3.790028311218491*^9, 3.7900283467190313`*^9, {3.790028673014132*^9, 3.7900286968352222`*^9}}, CellLabel-> "During evaluation of \ In[3682]:=",ExpressionUUID->"d8192d17-808d-4bf5-8ea8-3f493fd0591a"], Cell[BoxData["\<\"C quarterly for the period 1957-2019:\"\>"], "Print", CellChangeTimes->{ 3.7900272412197657`*^9, {3.7900272784199877`*^9, 3.790027296418367*^9}, { 3.790027817338188*^9, 3.790027832346726*^9}, {3.7900278632554197`*^9, 3.790027963799673*^9}, 3.790028280289846*^9, 3.790028311218491*^9, 3.7900283467190313`*^9, {3.790028673014132*^9, 3.790028696836972*^9}}, CellLabel-> "During evaluation of \ In[3682]:=",ExpressionUUID->"541ae6e1-b6b5-485a-8a61-dab440f94ee7"], Cell[BoxData["\<\"Y quarterly for the period 1947-2009:\"\>"], "Print", CellChangeTimes->{ 3.7900272412197657`*^9, {3.7900272784199877`*^9, 3.790027296418367*^9}, { 3.790027817338188*^9, 3.790027832346726*^9}, {3.7900278632554197`*^9, 3.790027963799673*^9}, 3.790028280289846*^9, 3.790028311218491*^9, 3.7900283467190313`*^9, {3.790028673014132*^9, 3.790028696838716*^9}}, CellLabel-> "During evaluation of \ In[3682]:=",ExpressionUUID->"c1402f0e-2f87-4f85-893f-a0c613e5730d"] }, Open ]] }, Open ]] }, WindowSize->{936, 547}, WindowMargins->{{Automatic, 0}, {Automatic, 260}}, FrontEndVersion->"12.0 for Mac OS X x86 (64-bit) (April 8, 2019)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[580, 22, 7791, 170, 808, "Input",ExpressionUUID->"205ec875-2237-47bd-840a-8d8150907d3f"], Cell[CellGroupData[{ Cell[8396, 196, 487, 8, 24, "Print",ExpressionUUID->"d8192d17-808d-4bf5-8ea8-3f493fd0591a"], Cell[8886, 206, 493, 8, 24, "Print",ExpressionUUID->"541ae6e1-b6b5-485a-8a61-dab440f94ee7"], Cell[9382, 216, 493, 8, 24, "Print",ExpressionUUID->"c1402f0e-2f87-4f85-893f-a0c613e5730d"] }, Open ]] }, Open ]] } ] *)