(*********************************************************************** 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[ 10458, 395]*) (*NotebookOutlinePosition[ 11577, 431]*) (* CellTagsIndexPosition[ 11533, 427]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["StationarityTests", "Title", TextAlignment->Center], Cell["by Luci Ellis", "Subsubtitle", TextAlignment->Center], Cell["\<\ This notebook is sets up several standard tests of stationarity and \ non-stationarity in time series.\ \>", "Text"], Cell[CellGroupData[{ Cell["Reference", "Section"], Cell[CellGroupData[{ Cell["Title", "Subsubsection"], Cell[TextData[StyleBox["StationarityTests", FontSlant->"Italic"]], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Author", "Subsubsection"], Cell["Luci Ellis", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Summary", "Subsubsection"], Cell["\<\ This notebook is sets up several standard tests of stationarity and \ non-stationarity in time series, including the Kwiatowski et. al. (1992) KPSS \ test..\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Copyright", "Subsubsection"], Cell["\<\ \[Copyright] Copyright 1997, Luci Ellis Permission is granted to distribute this file for any purpose except for \ inclusion in commercial software or program collections. This copyright \ notice must remain intact..\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Notebook Version", "Subsubsection"], Cell["1.0", "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " Version" }], "Subsubsection"], Cell["3.0", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["History", "Subsubsection"], Cell["Version 1.0, first implementation of KPSS test.", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Keywords", "Subsubsection"], Cell["Stationarity, non-stationarity, integration, cointegration", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Source", "Subsubsection"], Cell[TextData[{ "KPSS test from Kwiatkowski, D., Phillips, P.C.B., Schmidt, P. and Shin, Y. \ (1992),\[OpenCurlyDoubleQuote]Testing the null hypothesis of stationarity \ against the alternative of a unit root: how sure are we that economic time \ series have a unit root?\[CloseCurlyDoubleQuote], ", StyleBox["Jounal of Econometrics", FontSlant->"Italic"], ", ", StyleBox["54", FontWeight->"Bold"], ", 159\[Dash]178." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Warnings", "Subsubsection"], Cell[TextData[StyleBox["description of global effects, incompatibilities", FontSlant->"Italic"]], "Text"], Cell[TextData[{ "Note: all cells marked as \"InitializationCell\" will be written to the \ Auto-Save package. This package can then be read in programs that use it with \ ", StyleBox["Needs[\"Template`\"]", "Input"], ". Cells not intended to belong to the package should not have this \ property." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Limitation", "Subsubsection"], Cell[TextData[StyleBox["special cases not handled, known problems", FontSlant->"Italic"]], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Discussion", "Subsubsection"], Cell[TextData[StyleBox["description of algorithm, information for experts", FontSlant->"Italic"]], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Requirements", "Subsubsection"], Cell["\<\ \"Statistics`LinearRegression`\", \ \"Statistics`Common`MultivariateCommon`\", \"Statistics`Common`RegressionCommon`\", \"Statistics`ConfidenceIntervals`\", \"Statistics`Common`PopulationsCommon`\", \"Statistics`NormalDistribution`\", \"Statistics`Common`DistributionsCommon`\", \ \"Statistics`DescriptiveStatistics`\", \"Graphics`Animation`\"\ \>", "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Setup", "Section"], Cell["\<\ This section contains commands needed to load the corresponding \ package. It may be omitted for notebooks that are used only to generate an \ auto-save package.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Interface", "Section", InitializationCell->True], Cell["\<\ This part declares the publicly visible functions, options, and \ values.\ \>", "Text", InitializationCell->True], Cell[CellGroupData[{ Cell["Set up the package context, including public imports", "Subsection", InitializationCell->True], Cell["\<\ BeginPackage[\"EconGroup`StationarityTests`\", \ \"Statistics`LinearRegression`\", \"Statistics`Common`MultivariateCommon`\", \"Statistics`Common`RegressionCommon`\", \"Statistics`ConfidenceIntervals`\", \"Statistics`Common`PopulationsCommon`\", \"Statistics`NormalDistribution`\", \"Statistics`Common`DistributionsCommon`\", \ \"Statistics`DescriptiveStatistics`\", \"Graphics`Animation`\"]\ \>", "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Usage messages for the exported functions and the context \ itself\ \>", "Subsection", InitializationCell->True], Cell["\<\ StationarityTests::usage = \"StationarityTests.m is a package that \ provides tests of stationarity / non-stationarity for vectors of numeric \ data.\"\ \>", "Input", InitializationCell->True], Cell["\<\ KPSStest::usage = \"KPSStest[resids, l] computes the test statistic \ from Kwiatowski et. al. (1992) for a vector of numeric data, with a null \ hypothesis of stationarity, I(0).\"\ \>", "Input", InitializationCell->True], Cell["\<\ ResidualData::usage = \"ResidualData is an option to KPSStest, \ indicating if the data input is residuals from an existing equation or not. \ If ResidualData is True (the default), the test is performed on the existing \ data. If ResidualData is False, the input data is first regressed on a \ constant and a linear trend, and the test is performed on the resulting \ residuals.\"\ \>", "Input", InitializationCell->True] }, Open ]], Cell["Error messages for the exported objects", "Subsection", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell["Implementation", "Section", InitializationCell->True], Cell["\<\ This part contains the actual definitions and any auxiliary \ functions that should not be visible outside.\ \>", "Text"], Cell[CellGroupData[{ Cell["Begin the private context (implementation part)", "Subsection", InitializationCell->True], Cell["Begin[\"`Private`\"]", "Input", InitializationCell->True] }, Open ]], Cell["\<\ Definition of auxiliary functions and local (static) variables\ \>", "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell["Definition of the exported functions", "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell[TextData[StyleBox["KPSStest[]", "Input"]], "Subsubsection", InitializationCell->True], Cell["Options[KPSStest]={ResidualData->True}", "Input", InitializationCell->True], Cell["SetOptions[KPSStest,ResidualData->True]", "Input", InitializationCell->True], Cell[BoxData[ \(KPSStest[data : {__?NumericQ}, \[ScriptL]_Integer, opts___?OptionQ]\ := \ \nModule[{resids, restrue}, restrue\ = \((ResidualData /. Flatten[{opts}])\) /. Options[KPSStest]\ ; \ \t\n \t\tresids\ = \ If[restrue, data, FitResiduals /. Regress[data, {1, x}, {x}, RegressionReport -> {FitResiduals}]]; \n With[{\[ScriptCapitalT] = Length[resids]}, Plus@@\(( \((\(\((Plus\ @@Drop[resids, \(-#\)])\)&\)\ /@\ Range[\[ScriptCapitalT]])\)\^2)\)\[Divide]\(( \(\[ScriptCapitalT]\^2\) \((\(1\/\[ScriptCapitalT]\) Plus@@\((resids\^2)\) + \(2\/\[ScriptCapitalT]\) \((Plus@@ \((\(\((Plus@@ \((\((1 - #\/\(\[ScriptL] + 1\))\) \((Drop[resids, #]\ Drop[RotateRight[resids, #], #])\))\)) \)&\)/@Range[\[ScriptL]])\))\)\ )\))\)]]\)], "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["End the private context", "Subsection", InitializationCell->True], Cell["End[ ]", "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Epilog", "Section", InitializationCell->True], Cell["This section protects exported symbols and ends the package.", "Text"], Cell[CellGroupData[{ Cell["Protect exported symbol", "Subsection", InitializationCell->True], Cell["Protect[ KPSStest ]", "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell["End the package context", "Subsection", InitializationCell->True], Cell["EndPackage[ ]", "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Examples, Tests", "Section"], Cell[TextData[StyleBox[ "Examples, tests for the use of the package can go here.", FontSlant->"Italic"]], "Text"] }, Closed]] }, Open ]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 640}, {0, 460}}, AutoGeneratedPackage->Automatic, CellGrouping->Automatic, WindowSize->{632, 433}, WindowMargins->{{4, Automatic}, {Automatic, 1}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, 128}}, ShowCellLabel->True, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, Magnification->1, MacintoshSystemPageSetup->"\<\ 00<0004/0B`000003;H8`Omooh`=<`Tj0fL5N`?P0080004/0B`000000]P2:001 0000I00000400`<30?l00BL?00400@6edm000000000006P801T1T00000000000 00000000004000000000000000000000\>" ] (*********************************************************************** 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[CellGroupData[{ Cell[1731, 51, 59, 1, 70, "Title"], Cell[1793, 54, 61, 1, 33, "Subsubtitle"], Cell[1857, 57, 126, 3, 25, "Text"], Cell[CellGroupData[{ Cell[2008, 64, 28, 0, 44, "Section"], Cell[CellGroupData[{ Cell[2061, 68, 30, 0, 33, "Subsubsection"], Cell[2094, 70, 76, 1, 25, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2207, 76, 31, 0, 33, "Subsubsection"], Cell[2241, 78, 26, 0, 25, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2304, 83, 32, 0, 33, "Subsubsection"], Cell[2339, 85, 180, 4, 38, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2556, 94, 34, 0, 33, "Subsubsection"], Cell[2593, 96, 241, 6, 78, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[2871, 107, 41, 0, 23, "Subsubsection"], Cell[2915, 109, 19, 0, 25, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2971, 114, 101, 4, 42, "Subsubsection"], Cell[3075, 120, 19, 0, 30, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3131, 125, 32, 0, 41, "Subsubsection"], Cell[3166, 127, 63, 0, 30, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3266, 132, 33, 0, 41, "Subsubsection"], Cell[3302, 134, 74, 0, 30, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3413, 139, 31, 0, 41, "Subsubsection"], Cell[3447, 141, 447, 11, 64, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3931, 157, 33, 0, 41, "Subsubsection"], Cell[3967, 159, 107, 1, 31, "Text"], Cell[4077, 162, 315, 7, 63, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4429, 174, 35, 0, 27, "Subsubsection"], Cell[4467, 176, 100, 1, 31, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4604, 182, 35, 0, 27, "Subsubsection"], Cell[4642, 184, 108, 1, 31, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4787, 190, 37, 0, 27, "Subsubsection"], Cell[4827, 192, 367, 8, 94, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[5243, 206, 24, 0, 50, "Section"], Cell[5270, 208, 185, 4, 46, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[5492, 217, 56, 1, 50, "Section", InitializationCell->True], Cell[5551, 220, 125, 4, 30, "Text", InitializationCell->True], Cell[CellGroupData[{ Cell[5701, 228, 102, 1, 44, "Subsection", InitializationCell->True], Cell[5806, 231, 444, 9, 162, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[6287, 245, 124, 4, 44, "Subsection", InitializationCell->True], Cell[6414, 251, 204, 5, 57, "Input", InitializationCell->True], Cell[6621, 258, 233, 5, 57, "Input", InitializationCell->True], Cell[6857, 265, 434, 8, 102, "Input", InitializationCell->True] }, Open ]], Cell[7306, 276, 89, 1, 44, "Subsection", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[7432, 282, 61, 1, 50, "Section", InitializationCell->True], Cell[7496, 285, 131, 3, 30, "Text"], Cell[CellGroupData[{ Cell[7652, 292, 97, 1, 44, "Subsection", InitializationCell->True], Cell[7752, 295, 65, 1, 27, "Input", InitializationCell->True] }, Open ]], Cell[7832, 299, 123, 4, 44, "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell[7980, 307, 86, 1, 44, "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell[8091, 312, 92, 1, 41, "Subsubsection", InitializationCell->True], Cell[8186, 315, 83, 1, 27, "Input", InitializationCell->True], Cell[8272, 318, 84, 1, 27, "Input", InitializationCell->True], Cell[8359, 321, 1177, 24, 256, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[9585, 351, 73, 1, 44, "Subsection", InitializationCell->True], Cell[9661, 354, 51, 1, 27, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[9761, 361, 53, 1, 50, "Section", InitializationCell->True], Cell[9817, 364, 76, 0, 30, "Text"], Cell[CellGroupData[{ Cell[9918, 368, 73, 1, 44, "Subsection", InitializationCell->True], Cell[9994, 371, 64, 1, 27, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[10095, 377, 73, 1, 44, "Subsection", InitializationCell->True], Cell[10171, 380, 58, 1, 27, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[10278, 387, 34, 0, 50, "Section"], Cell[10315, 389, 115, 2, 31, "Text"] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)