(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing 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[ 6765, 207]*) (*NotebookOutlinePosition[ 7480, 232]*) (* CellTagsIndexPosition[ 7436, 228]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[ \(<< Statistics`ContinuousDistributions`\)], "Input"], Cell[BoxData[ \(<< Statistics`LinearRegression`\)], "Input"], Cell[BoxData[ \(Off[DesignedRegress::tsos]\)], "Input"], Cell[BoxData[ \(Off[DesignedRegress::rsqr]\)], "Input"], Cell[BoxData[ \(Off[General::spell1]\)], "Input"], Cell[CellGroupData[{ Cell[TextData[{ "The function 'p' generates the next price. The function path generates a \ price path with N observations, starting from an initial price of p", StyleBox["0 = 60. The function 'cEsttStat' finds estimates of 'c' and the \ t-statistic for a linear regression model and for a Dickey-Fuller test using \ a price path generated by the function 'path'. This function returns an \ estimate of 'c', its standard error, and its t-statistic for the OLS model \ (as its first three output values), and the same three statisitics from the \n\ Dickey-Fuller model (as its fourth through sixth output values).", "InlineFormula"] }], "Subsection"], Cell[BoxData[ \(p[h_] := \ Join[h, {h[\([\(-1\)]\)] + 0.02*\((91 - h[\([\(-1\)]\)])\) + Random[NormalDistribution[0, 1]]}]\)], "Input"], Cell[BoxData[ \(path[N_] := \ Nest[p, \ {60}, \ N\ - \ 1]\)], "Input"], Cell[BoxData[ \(cEsttStat[N_] := \ Module[{pr, \ pr1, \ pr2, \ d1, \ r1, \ c1, \ se1, \ t1, \ diff, \ lhs, \ rhs, \ d2}, \[IndentingNewLine]pr\ = \ path[N]; \[IndentingNewLine] (*\ OLS\ estimates\ *) \ \[IndentingNewLine]pr1\ = \ Drop[pr, \ \(-1\)]; \[IndentingNewLine]pr2\ = \ Drop[pr, \ 1]; \[IndentingNewLine]d1\ = \ Transpose[{pr1, \ pr2}]; \[IndentingNewLine]r1\ = \ Regress[d1, \ {1, \ x}, \ x]; \[IndentingNewLine]c1\ = \ \(\(\(\(r1[\([1]\)]\)[\([2]\)]\)[\ \([1]\)]\)[\([2]\)]\)[\([1]\)]; \[IndentingNewLine]se1\ = \ \(\(\(\(r1[\([1]\ \)]\)[\([2]\)]\)[\([1]\)]\)[\([2]\)]\)[\([2]\)]; \[IndentingNewLine]t1\ = \ \ \((1\ - \ c1)\)/se1; \[IndentingNewLine] (*\ Dickey - Fuller\ estimates\ *) \ \[IndentingNewLine]diff\ = \ pr\ - \ 91; \[IndentingNewLine]lhs\ = \ Drop[diff, \ 1]\ - \ Drop[diff, \ \(-1\)]; \[IndentingNewLine]rhs\ = \ \(-\ Drop[diff, \ \(-1\)]\); \[IndentingNewLine]d2\ = \ Transpose[{rhs, \ lhs}]; \[IndentingNewLine]r2\ = \ Regress[d2, \ {x}, \ x, \ IncludeConstant\ \[Rule] \ False]; \[IndentingNewLine]c2\ = \ \(\(\(\(r2[\([1]\)]\)[\([2]\ \)]\)[\([1]\)]\)[\([1]\)]\)[\([1]\)]; \[IndentingNewLine]se2\ = \ \ \(\(\(\(r2[\([1]\)]\)[\([2]\)]\)[\([1]\)]\)[\([1]\)]\)[\([2]\)]; \ \[IndentingNewLine]t2\ = \ \(\(\(\(r2[\([1]\)]\)[\([2]\)]\)[\([1]\)]\)[\([1]\)]\)[\([3]\)]; \ \[IndentingNewLine]{c1, \ se1, \ t1, \ c2, \ se2, \ t2}]\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Simulations with 46 price observations ", "Subsection"], Cell[BoxData[ \(\(data\ = \ Transpose[Table[cEsttStat[45], \ {i, \ 1, \ 10000}]];\)\)], "Input"], Cell[CellGroupData[{ Cell["\<\ The first vector in 'data' is a list of values of the estimates '1 - a' for \ OLS. The fourth vector in 'data' is a list of estiamtes of 'a' from the \ Dickey-Fuller test. The mean of the estimate from OLS is almost twice the \ actual value (a = 0.02), whereas the mean of the estimates from the \ Dicley-Fuller test is close to the actual parameter value.\ \>", "Subsubsection"], Cell[CellGroupData[{ Cell[BoxData[ \({1 - \ Mean[data[\([1]\)]], \ Mean[data[\([4]\)]]}\)], "Input"], Cell[BoxData[ \({0.03902436468098058`, 0.021632414714995545`}\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ The 95th percentile of the t distribution with 44 degrees of freedom is \ 1.68023.\ \>", "Subsubsection"], Cell[CellGroupData[{ Cell[BoxData[ \(Quantile[StudentTDistribution[44], \ 0.95]\)], "Input"], Cell[BoxData[ \(1.6802299765721191`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(CDF[StudentTDistribution[44], \ 1.68023]\)], "Input"], Cell[BoxData[ \(0.9500000022934654`\)], "Output"] }, Open ]], Cell[BoxData[ \(f[y_] := \ If[y\ < \ 1.68023, \ 1, \ 0]\)], "Input"], Cell[BoxData[ \(TypeIIerrorsOLS[d_] := \ Module[{x}, \ \[IndentingNewLine]x\ = \ Map[f, \ Sort[d[\([3]\)]]]; \[IndentingNewLine]Sum[ x[\([i]\)], \ {i, \ 1, \ Length[d[\([3]\)]]}]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(TypeIIerrorsOLS[data]\)], "Input"], Cell[BoxData[ \(6487\)], "Output"] }, Open ]], Cell[BoxData[ \(g[y_] := \ If[y\ < \ 1.95, \ 1, \ 0]\)], "Input"], Cell[BoxData[ \(TypeIIerrorsDF[d_] := \ Module[{x}, \ \[IndentingNewLine]x\ = \ Map[g, \ Sort[d[\([6]\)]]]; \[IndentingNewLine]Sum[ x[\([i]\)], \ {i, \ 1, \ Length[d[\([6]\)]]}]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(TypeIIerrorsDF[data]\)], "Input"], Cell[BoxData[ \(675\)], "Output"] }, Open ]] }, Open ]] }, Open ]] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 685}}, WindowSize->{692, 527}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic} ] (*********************************************************************** 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[1717, 49, 71, 1, 30, "Input"], Cell[1791, 52, 64, 1, 30, "Input"], Cell[1858, 55, 59, 1, 30, "Input"], Cell[1920, 58, 59, 1, 30, "Input"], Cell[1982, 61, 53, 1, 30, "Input"], Cell[CellGroupData[{ Cell[2060, 66, 661, 10, 142, "Subsection"], Cell[2724, 78, 159, 3, 30, "Input"], Cell[2886, 83, 75, 1, 30, "Input"], Cell[2964, 86, 1591, 27, 410, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[4592, 118, 61, 0, 47, "Subsection"], Cell[4656, 120, 110, 2, 30, "Input"], Cell[CellGroupData[{ Cell[4791, 126, 392, 6, 77, "Subsubsection"], Cell[CellGroupData[{ Cell[5208, 136, 83, 1, 30, "Input"], Cell[5294, 139, 79, 1, 29, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[5422, 146, 115, 3, 43, "Subsubsection"], Cell[CellGroupData[{ Cell[5562, 153, 75, 1, 30, "Input"], Cell[5640, 156, 53, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[5730, 162, 73, 1, 30, "Input"], Cell[5806, 165, 53, 1, 29, "Output"] }, Open ]], Cell[5874, 169, 73, 1, 30, "Input"], Cell[5950, 172, 225, 4, 70, "Input"], Cell[CellGroupData[{ Cell[6200, 180, 54, 1, 30, "Input"], Cell[6257, 183, 38, 1, 29, "Output"] }, Open ]], Cell[6310, 187, 70, 1, 30, "Input"], Cell[6383, 190, 224, 4, 70, "Input"], Cell[CellGroupData[{ Cell[6632, 198, 53, 1, 30, "Input"], Cell[6688, 201, 37, 1, 29, "Output"] }, Open ]] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)