(*********************************************************************** 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[ 41426, 1064]*) (*NotebookOutlinePosition[ 42498, 1098]*) (* CellTagsIndexPosition[ 42454, 1094]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["EconGroup`EGFiltering", "Title", TextAlignment->Center], Cell["\<\ Code by Luci Ellis, based on template by Roman E. Maeder, Programming in \ Mathmatica, 3rd Edition\ \>", "Subsubtitle", TextAlignment->Center], Cell[TextData[{ "This notebook forms the basis of a package for various methods of time \ series filtering not contained in the standard release of ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"], Cell[CellGroupData[{ Cell["Reference", "Section"], Cell[CellGroupData[{ Cell["Title", "Subsubsection"], Cell[TextData[StyleBox["EGFiltering", FontSlant->"Italic"]], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Author", "Subsubsection"], Cell["Luci B. Ellis", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Summary", "Subsubsection"], Cell[TextData[{ "This notebook forms the basis of a package for various methods of data \ filtering not contained in the standard release of ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Copyright", "Subsubsection"], Cell["\<\ \[Copyright] Copyright 1997-9, 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"] }, Open ]], Cell[CellGroupData[{ Cell["Notebook Version", "Subsubsection"], Cell["2.0", "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " Version" }], "Subsubsection"], Cell["3.0", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["History", "Subsubsection"], Cell["\<\ Version 1.0 implemented Hodrick-Prescott filter, 15 July 1997. Version 2.0 implemented Henderson moving average weights, 21 February 1999.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Keywords", "Subsubsection"], Cell["\<\ data smoothing, filters, Hodrick-Prescott, Henderson moving average \ weights.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Source", "Subsubsection"], Cell[TextData[ "Hodrick, R.J. and E.C. Prescott (1980) \[OpenCurlyDoubleQuote]Postwar US \ Business Cycles: An Empirical Investigation\[CloseCurlyDoubleQuote], Carnegie \ Mellon University Discussion Paper No. 451.\nAustralian Bureau of Statistics \ \[OpenCurlyDoubleQuote]A Guide to Smoothing Time Series\ \[CloseCurlyDoubleQuote] Cat. No 1301.0.\nNote that there appears to be a \ typographical error in the printed tables for the 17 term averages (the signs \ of a couple of the weights are shown as positive when they need to be \ negative to ensure the weights add to 1). These have been corrected in this \ implementation."], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Warnings", "Subsubsection"], Cell[TextData[StyleBox[ "No global effects or limitations currently known. Please report all bugs to \ Luci Ellis at elisha@dot.net.au", FontSlant->"Italic"]], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Limitation", "Subsubsection"], Cell[TextData[StyleBox[ "The Henderson moving average procedure is only valid for 5, 7, 9, 13, 15, 17 \ and 23-term averages.", FontSlant->"Plain"]], "Text", FontSlant->"Italic"] }, Open ]], Cell[CellGroupData[{ Cell["Discussion", "Subsubsection"], Cell[TextData[{ "The Hodrick-Prescott filter works by finding the values ", Cell[BoxData[ \(TraditionalForm\`\[Tau]\_t, \ t = 1 \[Ellipsis]\)]], "\[DoubleStruckCapitalT] that minimise:\n\t\[ScriptCapitalL] = ", Cell[BoxData[ \(TraditionalForm \`\[Sum]\+\(t = 1\)\%\[DoubleStruckCapitalT]\(( y\_\(t - 1\) - \[Tau]\_\(t - 1\))\)\^2 + \[Lambda] \(\[Sum]\+\(t = 1\)\%\[DoubleStruckCapitalT]\(( \[CapitalDelta]\[Tau]\_\(t + 1\) - \[CapitalDelta]\[Tau]\_t) \)\^2\)\)]], "\nThe value for \[Lambda] is typically 1600, but this is not required to \ be the case.\nThe first-order conditions for this minimisation problem are \ linear and have a simple structure, so that the algorithm constructs the \ first-order conditions directly rather than constructing the loss function \ and differentiating it with respect to each \[Tau]. This reduces the \ computational time substantially." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Requirements", "Subsubsection"], Cell["\<\ Statistics`DataSmoothing required for MovingAverage[] command.\ \>", "Text"] }, Open ]] }, 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`EGFiltering`\",\"Statistics`DataSmoothing`\"]\ \>", "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Usage messages for the exported functions and the context itself\ \>", "Subsection", InitializationCell->True], Cell["\<\ EGFiltering::usage = \"EGFiltering.m is a package containing various \ functions for smoothing and filtering data, including Henderson moving \ averages and the univariate Hodrick-Prescott filter.\"\ \>", "Input", InitializationCell->True], Cell[TextData[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "::usage=\"", StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "[data,MAOrder] calculates a long-term trend-cycle component of a time \ series using applications of a Henderson moving average. You may want to \ Nest[] this function. Data is assumed monthly unless specified otherwise \ using the DataFrequency option. The MAOrder must be one of the standard ones \ -- 5,7,9,13,15,17,23.\"" }], "Input", InitializationCell->True], Cell["\<\ HendersonMovingAverage::usage=\"HendersonMovingAverage[data,Order] calculates \ a Henderson moving average. Unlike other moving average procedures, this one \ does not lose data points, but the endpoints are liable to be revised as new \ data comes in. Order must be an integer from the list \ {5,7,9,13,15,17,23}.\"\ \>", "Input", InitializationCell->True], Cell["\<\ HendersonMid::usage=\"HendersonMid[Order] provides the middle part of the \ Henderson MA weights. Order must be an integer from the list \ {5,7,9,13,15,17,23}.\"\ \>", "Input", InitializationCell->True], Cell["\<\ HendersonStart::usage=\"HendersonStart[Order] provides the beginning part of \ the Henderson MA weights. Order must be an integer from the list \ {5,7,9,13,15,17,23}.\"\ \>", "Input", InitializationCell->True], Cell["\<\ HendersonEnd::usage=\"HendersonEnd[Order] provides the end part of the \ Henderson MA weights. Order must be an integer from the list \ {5,7,9,13,15,17,23}.\"\ \>", "Input", InitializationCell->True], Cell[TextData[{ "DataFrequency::usage=\"DataFrequency is an option to ", StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], " that specifies the periodicity of the data. It can take a positive \ integer value, or one of Daily, Weekly, Monthly, Quarterly or those words as \ Strings (in quote marks).\"" }], "Input", InitializationCell->True], Cell[TextData[{ "SeasonalityAveraging::usage=\"SeasonalityAveraging is an option to ", StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], " that specifies the number of years of data to put in the moving average \ to get rid of seasonal effects.\"" }], "Input", InitializationCell->True], Cell["\<\ hendersonweights::usage = \"hendersonweights[n] gives the list of weights to \ be used in the LinearFilter function to perform a n-term Henderson Moving \ Average. The start and end-point weights are not used.\"\ \>", "Input", InitializationCell->True], Cell["\<\ HPFilter::usage = \"HPFilter[data,lambda] performs a Hodrick-Prescott filter \ on data, with a weight on smoothness of lambda (usually 1600 for quarterly \ data). Data can be a vector or a matrix; in the latter case, the filter is \ applied to individual rows in the matrix.\"\ \>", "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell["Error messages for the exported objects", "Subsection", InitializationCell->True], Cell[TextData[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "::badfreq=\"DataFrequency option must be a positive integer, or one of \ Daily, Weekly, Monthly or Quarterly.\"" }], "Input", InitializationCell->True], Cell[TextData[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "::negord=\"Order of Henderson moving average must be positive and one of \ the values 5,7,9,13,15,17,23. Pick 13, it works well.\"" }], "Input", InitializationCell->True], Cell[TextData[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "::badord=\"Order of Henderson moving average must be one of the values \ 5,7,9,13,15,17,23. The value `1` is not appropriate. Pick 13, it works \ well.\"" }], "Input", InitializationCell->True], Cell[TextData[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "::negord=\"Order of Henderson moving average must be positive and one of \ the values 5,7,9,13,15,17,23. Pick 13, it works well.\"" }], "Input", InitializationCell->True], Cell["\<\ HendersonMovingAverage::badord=\"Order of Henderson moving average must be \ one of the values 5,7,9,13,15,17,23. The value `1` is not appropriate. Pick \ 13, it works well.\"\ \>", "Input", InitializationCell->True], Cell["\<\ HendersonMovingAverage::badlen=\"Length of data series must be greater than \ order of moving average process.\"\ \>", "Input", InitializationCell->True] }, Open ]] }, 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["Read in any hidden imports", "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell["\<\ Definition of auxiliary functions and local (static) variables\ \>", "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell["hendersonweights", "Subsubsection", InitializationCell->True], Cell[BoxData[ \(hendersonweights[n_Integer] /; \ \ \((n == 5\ || \ n == 7\ || \ n == 9\ || \ n == 13\ || \ n == 15\ || \ n == 17\n || \ n == 23\ )\)\ \ := HendersonMid[n]\)], "Input", InitializationCell->True], Cell[BoxData[ \(HendersonMid[5] = \ {\(-0.073\), \ 0.294, \ 0.558, \ 0.294, \ \(-0.073\)}\ ; \n HendersonMid[7] = \ {\(-0.059\), \ 0.059, \ 0.294, \ 0.412, \ 0.294, \ 0.059, \ \(-0.059\)}\ ; \n HendersonMid[9] = \ {\(-0.041\), \ \(-0.010\), \ 0.119, \ 0.267, \ 0.33, \ 0.267, \ 0.119, \ \(-0.010\), \(-0.041\)}\ ; \n HendersonMid[13] = \n{\(-0.019\), \(-0.028\), 0, 0.066, 0.147, 0.214, 0.24, 0.214, 0.147, 0.066, 0, \(-0.028\), \(-0.019\)}\ ; \n HendersonMid[15] = \ {\ \(-0.014\), \ \(-0.024\), \(-0.014\), 0.024, 0.083, \ 0.146, \ 0.194, \ 0.212, \n0.194, \ 0.146, \ 0.083, \ 0.024, \ \(-0.014\), \ \(-0.024\), \(-0.014\)}\ ; \n HendersonMid[17] = \ {\(-0.009\), \ \(-0.02\), \ \(-0.019\), \ 0.002, \ 0.042, \ 0.092, \ 0.141, \ 0.176, \ 0.190, \ 0.176, \ \n\ \ \ \ \ \ 0.141, \ 0.092, \ 0.042, \ 0.002, \ \(-0.019\), \ \(-0.02\), \ \(-0.009\)}\ ; \n HendersonMid[23] = \ {\(-0.004\), \(-0.011\), \(-0.016\), \(-0.015\), \(-0.005\), \ 0.013, \ 0.039, \ 0.068, \n0.097, \ 0.122, \ 0.138, \ 0.148, \ 0.138, \ 0.122, \ 0.097, \ 0.068, \ 0.039, \ 0.013, \n\(-0.005\), \ \(-0.015\), \ \(-0.016\), \ \(-0.011\), \ \(-0.004\)}\ ; \)], "Input",\ InitializationCell->True], Cell[BoxData[ \(HendersonEnd[5] = {{0, 0, \(-0.073\), 0.403, 0.670}, \ \n{0, \(-0.073\), \ 0.294, 0.522, 0.257}, \ \n{\(-0.073\), \ 0.294, \ 0.558, \ 0.294, \ \(-0.073\)}\ }\ ; \n HendersonStart[5] = {{0.670, 0.403, \(-0.073\), 0, 0}, \ \n{\ 0.257, 0.522, 0.294, \(-0.073\), 0}, \ \n{\(-0.073\), \ 0.294, \ 0.558, \ 0.294, \ \(-0.073\)}\ }\ ; \)], "Input", InitializationCell->True], Cell[BoxData[ \(HendersonEnd[7] = \n{{0, 0, 0, \(-0.034\), 0.116, 0.383, 0.535}, \n{0, 0, \(-0.054\), 0.061, 0.294, 0.41, 0.289}, \n{0, \(-0.053\), 0.058, 0.287, 0.399, 0.275, 0.034}, \ \n{\(-0.059\), \ 0.059, \ 0.294, \ 0.412, \ 0.294, \ 0.059, \ \(-0.059\)}\ }; \n HendersonStart[7] = {{0.535, 0.383, 0.116, \(-0.034\), 0, 0, 0}, \n \t\t{0.289, 0.41, 0.294, 0.061, \(-0.054\), 0, 0}, {0.034, \ 0.275, \ 0.399, 0.287, 0.058, \(-0.053\), 0}, {\(-0.059\), 0.059, 0.294, 0.412, 0.294, 0.059, \(-0.059\)}}; \)], "Input", InitializationCell->True], Cell[BoxData[ \(HendersonEnd[9] = { \n{0, 0, 0, 0, \(-0.156\), \(-0.034\), 0.185, 0.424, 0.581}\ , \n{0, 0, 0, \(-0.049\), \(-0.011\), 0.126, 0.282, 0.354, 0.298}, \ \n{0, 0, \(-0.022\), 0, 0.12, 0.259, 0.315, 0.242, 0.086}, \ \n{0, \(-0.031\), \(-0.004\), 0.12, 0.263, 0.324, 0.255, 0.102, \(-0.029\)}, \ \n{\(-0.041\), \ \(-0.010\), \ 0.119, \ 0.267, \ 0.33, \ 0.267, \ 0.119, \ \(-0.010\)\ , \ \(-0.041\)}}; \n HendersonStart[9] = {\n \t{0.581, \ 0.424, \ 0.185, \ \(-0.034\), \ \(-0.156\), \ 0, \ 0, \ 0, \ 0}, \ \n \ \ {0.298, \ 0.354, \ 0.282, \ 0.126, \ \(-0.011\), \ \(-0.049\), \ 0, \ 0, \ 0}, \ \n \ \ {0.086, \ 0.242, \ 0.315, \ 0.259, \ 0.12, \ 0, \ \(-0.022\), \ 0, \ 0}, \ \n \ \ {\(-0.029\), \ 0.102, \ 0.255, \ 0.324, \ 0.263, \ \ 0.12, \ \(-0.004\), \ \(-0.031\), \ 0}, \ \n \ \ {\(-0.041\), \ \(-0.01\), \ 0.119, \ 0.267, \ 0.33, \ 0.267, \ 0.119, \ \(-0.01\), \ \(-0.041\)}}; \)], "Input", InitializationCell->True], Cell[BoxData[ \(HendersonEnd[13] = { \n{0, 0, 0, 0, 0, 0, \(-0.092\), \(-0.058\), 0.012, 0.12, 0.244, 0.353, 0.421}, \n{0, 0, 0, 0, 0, \(-0.043\), \(-0.038\), 0.002, 0.08, 0.174, 0.254, 0.292, 0.279}, \ \n{0, 0, 0, 0, \(-0.016\), \(-0.025\), 0.003, 0.068, 0.149, 0.216, 0.241, 0.216, 0.148}, \n{0, 0, 0, \(-0.009\), \(-0.022\), 0.004, 0.066, 0.145, 0.208, 0.230, 0.201, 0.131, 0.046}, \n{0, 0, \(-0.011\), \(-0.022\), 0.003, 0.067, 0.145, 0.21, 0.235, 0.205, 0.136, 0.050, \(-0.018\)}, \n{0, \(-0.017\), \(-0.025\), 0.001, 0.066, 0.147, 0.213, 0.238, 0.212, 0.144, 0.061, \(-0.006\), \(-0.034\)}, \n{\(-0.019\), \(-0.028\), 0, 0.066, 0.147, 0.214, 0.24, 0.214, 0.147, 0.066, 0, \(-0.028\), \(-0.019\)}\n}; \n HendersonStart[13] = {{0.421, \ 0.353, \ 0.244, \ 0.120, \ \ 0.0120, \ \(-0.058\), \ \(-0.092\), \ 0, \ 0, \ 0, \ 0, \ 0, \ 0}, \ \n \ \ {0.279, \ 0.292, \ 0.254, \ 0.174, \ 0.08, \ 0.002, \ \ \(-0.038\), \ \(-0.043\), \ 0, \ 0, \ 0, \ 0, \ 0}, \ \n \ \ {0.148, \ 0.216, \ 0.241, \ 0.216, \ 0.149, \ 0.068, \ 0.003, \ \(-0.025\), \ \(-0.016\), \ \ 0, \ 0, \ 0, \ 0}, \ \n \t{0.046, \ 0.131, \ 0.201, \ 0.230, 0.208, \ 0.145, \ 0.066, \ 0.004, \ \(-0.022\), \ \(-0.009\), \ 0, \ 0, \ 0}, \ \n \ \ {\(-0.0180\), \ 0.05, \ 0.136, \ 0.205, \ 0.235, \ 0.21, \ 0.145, \ 0.067, \ 0.003, \ \(-0.022\), \ \(-0.011\), \ 0, \ 0}, \ \n \ \ {\(-0.034\), \ \(-0.006\), \ 0.061, \ 0.144, 0.212, \ \ 0.238, \ 0.213, \ 0.147, \ 0.066, \ 0.001, \ \ \(-0.025\), \ \(-0.017\), \ 0}, \ \n\t{\(-0.019\), \ \(-0.028\), \ 0, \ 0.066, \ 0.147, \ 0.214, \ 0.240, \ 0.214, \ 0.147, \ 0.066, \ 0, \ \(-0.028\), \ \(-0.019\)}}; \)], "Input", InitializationCell->True], Cell[BoxData[ \(HendersonEnd[15] = { \n{0, 0, 0, 0, 0, 0, 0, \(-0.079\), \(-0.057\), \(-0.014\), 0.057, 0.149, 0.244, 0.325, 0.375}\ , \n{0, 0, 0, 0, 0, 0, \(-0.04\), \(-0.039\), \(-0.016\), 0.034, 0.105, 0.18, 0.24, 0.27, 0.265}, \n{0, 0, 0, 0, 0, \(-0.016\), \(-0.025\), \(-0.013\), 0.027, 0.088, 0.152, 0.202, 0.221, 0.205, 0.159}, \n{0, 0, 0, 0, \(-0.005\), \(-0.018\), \(-0.01\), 0.026, 0.083, 0.143, 0.189, 0.205, 0.185, 0.135, 0.069}, \n{0, 0, 0, \(-0.005\), \(-0.018\), \(-0.01\), 0.026, 0.082, 0.143, 0.188, 0.203, 0.183, 0.133, 0.067, 0.006}, \ \n{0, 0, \(-0.008\), \(-0.02\), \(-0.011\), 0.025, 0.083, 0.144, 0.191, 0.207, 0.188, 0.139, 0.074, 0.014, \(-0.026\)}, \ \n{0, \(-0.012\), \(-0.023\), \(-0.013\), 0.025, 0.083, 0.146, 0.193, 0.210, 0.192, 0.144, 0.080, 0.021, \(-0.017\), \(-0.028\)}, \ \n{\ \(-0.014\), \ \(-0.024\), \(-0.014\), 0.024, 0.083, \ 0.146, \ 0.194, \ 0.212, \ 0.194, \ 0.146, 0.083, \ 0.024, \ \(-0.014\), \ \(-0.024\), \(-0.014\)}\ }; \n HendersonStart[15] = {\n \t\t{0.375, \ 0.325, \ 0.244, \ 0.149, \ 0.0570, \ \(-0.014\), \ \(-0.057\), \ \(-0.079\), \ 0, \ 0, \ 0, \ 0, \ 0, \ 0, \ 0}, \ \n{0.265, \ 0.27, \ 0.240, \ 0.180, \ 0.105, \ 0.034, \ \(-0.016\), \ \ \(-0.039\), \ \(-0.04\), \ 0, \ 0, \ 0, \ 0, \ 0, \ 0}, \ \n{0.159, \ 0.205, \ 0.221, \ 0.202, \ 0.152, \ \ 0.088, \ 0.027, \ \(-0.013\), \ \(-0.025\), \ \(-0.016\), \ 0, \ 0, \ 0, \ 0, \ 0}, \ \n{0.069, \ 0.135, \ 0.185, \ 0.205, \ 0.189, \ 0.143, \ 0.083, \ \ 0.026, \ \(-0.01\), \ \(-0.018\), \ \(-0.005\), \ 0, \ 0, \ 0, \ 0}, \ \n{0.006, \ 0.067, \ 0.133, \ 0.183, \ 0.203, \ 0.188, \ 0.143, \ 0.082, \ 0.026, \ \(-0.01\), \ \(-0.018\), \ \(-0.005\), \ 0, \ 0, \ 0}, \ \n{\(-0.026\), \ 0.014, \ 0.074, \ 0.139, \ 0.188, \ 0.207, \ 0.191, \ \n\ \ \ 0.144, \ 0.083, \ 0.025, \ \(-0.011\), \ \(-0.02\), \ \(-0.008\), \ 0, \ 0}, \ \n{\(-0.028\), \ \(-0.017\), \ 0.021, \ 0.08, \ 0.144, \ 0.192, \ 0.21, \ 0.193, \ 0.146, \ 0.083, \ 0.025, \ \(-0.013\), \ \(-0.023\), \ \(-0.012\), \ 0}, \ \n{\(-0.014\), \ \(-0.024\), \ \(-0.014\), \ \ 0.024, \ 0.083, \ 0.146, \ 0.194, \ 0.212, \ \ 0.194, \ 0.146, \ 0.083, \ 0.024, \ \(-0.014\), \ \ \(-0.024\), \ \(-0.014\)}}; \)], "Input", InitializationCell->True], Cell["\<\ HendersonEnd[17] = {{0, 0, 0, 0, 0, 0, 0, 0, -0.081, -0.062, -0.032, 0.018, 0.087, 0.166, \ 0.244, 0.309, 0.351}, {0, 0, 0, 0, 0, 0, 0, -0.042, -0.04, -0.026, 0.007, 0.059, 0.121, 0.182, \ 0.23, 0.255, 0.254}, {0, 0, 0, 0, 0, 0, -0.017, -0.025, -0.02, 0.004, 0.047, 0.101, 0.152, 0.191, 0.206, 0.197, 0.164}, {0, 0, 0, 0, 0, -0.005, -0.016, -0.015, 0.005, 0.043, 0.092, 0.14, 0.174, \ 0.186, 0.172, 0.136, 0.086}, {0, 0, 0, 0, -0.001, -0.013, -0.014, 0.005, 0.043, 0.091, 0.138, 0.171, 0.181, 0.167, 0.129, 0.078, 0.026}, {0, 0, 0, -0.003, -0.015, -0.015, 0.005, 0.043, 0.091, 0.138, 0.172, 0.183, 0.169, 0.132, 0.081, 0.029, -0.012}, {0, 0, -0.006, -0.017, -0.016, 0.004, 0.043, 0.092, 0.14, 0.174, 0.186, 0.173, 0.137, 0.087, 0.036, -0.005, -0.027}, {0, -0.009, -0.019, -0.018, 0.003, 0.042, 0.092, 0.141, 0.176, 0.188, 0.175, 0.14, 0.091, 0.04, 0.001, -0.021, -0.023}, {-0.009, -0.02, -0.019, 0.002, 0.042, 0.092, 0.141, 0.176, 0.190, 0.176, 0.141, 0.092, 0.042, 0.002, -0.019, -0.02, -0.009}}; HendersonStart[17] = {{0.351, 0.309, 0.244, 0.166, 0.087, 0.018, -0.032, -0.062, -0.081, 0, 0, \ 0, 0, 0, 0, 0, 0}, {0.254, 0.255, 0.23, 0.182, 0.121, 0.059, 0.007, -0.026, -0.04, -0.042, \ 0, 0, 0, 0, 0, 0, 0}, {0.164, 0.197, 0.206, 0.191, 0.152, 0.101, 0.047, 0.004, -0.02, -0.025, -0.017, 0, 0, 0, 0, 0, 0}, {0.086, 0.136, 0.172, 0.186, 0.174, 0.14, 0.092, 0.043, 0.005, -0.015, -0.016, -0.005, 0, 0, 0, 0, 0}, {0.026, 0.078, 0.129, 0.167, 0.181, 0.171, 0.138, 0.091, 0.043, 0.005, -0.014, -0.013, -0.001, 0, 0, 0, 0}, {-0.012, 0.029, 0.081, 0.132, 0.169, 0.183, 0.172, 0.138, 0.091, 0.043, 0.005, -0.015, -0.015, -0.003, 0, 0, 0}, {-0.027, -0.005, 0.036, 0.087, 0.137, 0.173, 0.186, 0.174, 0.14, 0.092, 0.043, 0.004, -0.016, -0.017, -0.006, 0, 0}, {-0.023, -0.021, 0.001, 0.04,0.091, 0.14, 0.175, 0.188, 0.176, 0.141, 0.092, 0.042, 0.003, -0.018, -0.019, -0.009, 0}, {-0.009, -0.02, -0.019, 0.002, 0.042, 0.092, 0.141, 0.176, 0.190, 0.176, 0.141, 0.092, 0.042, 0.002, -0.019, -0.02, -0.009}}; \ \>", "Input", InitializationCell->True], Cell["\<\ HendersonEnd[23] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.077, -0.064, -0.049, -0.028, 0.002, 0.039, 0.084, 0.133, 0.1819999999999999, 0.227, 0.2629999999999999, 0.2879999999999999}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.04599999999999999, -0.041, -0.035, -0.02399999999999999, -0.004, 0.025, \ 0.06099999999999999, 0.101, 0.1409999999999999, 0.1759999999999999, 0.203, \ 0.2189999999999999, 0.224}, {0, 0, 0, 0, 0, 0, 0, 0, 0, -0.02199999999999999, -0.025, -0.025, -0.019, -0.005, 0.01799999999999999, 0.049, 0.08200000000000001, 0.116, 0.1459999999999999, 0.166, 0.177, 0.1759999999999999, 0.166}, {0, 0, 0, 0, 0, 0, 0, 0, -0.008, -0.014, -0.01799999999999999, -0.015, -0.004, 0.015, 0.042, 0.07299999999999999, 0.103, 0.129, \ 0.1469999999999999, 0.154, 0.15, 0.134, 0.112}, {0, 0, 0, 0, 0, 0, 0, -0.001, -0.008, \ -0.013, -0.01199999999999999, -0.003, 0.015, 0.04009999999999999, 0.06809999999999999, 0.0981, 0.1211, 0.1370999999999999, 0.1421, 0.1350999999999999, 0.1191, 0.09510000000000001, 0.0661}, {0, 0, 0, 0, 0, 0, 0.003, -0.006, -0.01099999999999999, \ -0.01099999999999999, -0.002, 0.015, 0.039, 0.067, 0.095, 0.1189999999999999, 0.134, 0.139, \ 0.131, 0.114, 0.08799999999999998, 0.05899999999999999, 0.027}, {0, 0, 0, 0, 0, 0.002, -0.006, -0.01199999999999999, \ -0.01099999999999999, -0.003, 0.015, 0.039, 0.068, 0.09599999999999999, 0.1179999999999999, \ 0.134, 0.138, 0.132, 0.114, 0.08899999999999998, 0.05899999999999999, 0.027, \ 0.001}, {0, 0, 0, 0, 0.001, -0.007, -0.013, -0.01099999999999999, -0.003, 0.015, 0.039, 0.068, 0.09599999999999999, 0.1199999999999999, 0.135, 0.14, \ 0.133, 0.116, 0.09, 0.06, 0.031, 0.005, -0.015}, {0, 0, 0, -0.002, -0.007, -0.013, -0.013, -0.003, 0.014, 0.039, 0.068, 0.09699999999999999, 0.1199999999999999, 0.137, 0.14, 0.136, 0.1179999999999999, 0.09399999999999998, 0.064, 0.034, 0.008, -0.01, \ -0.021}, {0, 0, -0.003, -0.01, -0.015, -0.014, -0.005, 0.014, 0.04, 0.069, 0.09699999999999999, 0.1219999999999999, 0.138, 0.1429999999999999, \ 0.137, 0.1199999999999999, 0.095, 0.067, 0.037, 0.01099999999999999, -0.007, -0.017, -0.019}, {0, -0.004, -0.01099999999999999, -0.016, -0.015, \ -0.005, 0.013, 0.039, 0.068, 0.09699999999999999, 0.1219999999999999, 0.138, 0.1439999999999999, 0.138, 0.1219999999999999, 0.09699999999999999, \ 0.068, 0.039, 0.013, -0.005, -0.015, -0.016, -0.01099999999999999}, {-0.004, -0.01099999999999999, -0.016, -0.015, -0.005, 0.013, 0.039, \ 0.068, 0.09699999999999999, 0.1219999999999999, 0.138, 0.1479999999999999, \ 0.138, 0.1219999999999999, 0.09699999999999999, 0.068, 0.039, 0.013, -0.005, \ -0.015, -0.016, -0.01099999999999999, -0.004}}; HendersonStart[23] = {{0.288, 0.263, 0.227, 0.1819999999999999, 0.133, 0.084, 0.039, 0.002, -0.028, -0.049, -0.064, -0.077, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0}, {0.224, 0.2189999999999999, 0.203, 0.1759999999999999, 0.1409999999999999, 0.101, 0.06099999999999999, 0.025, -0.004, -0.02399999999999999, -0.035, -0.041, -0.04599999999999999, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0}, {0.166, 0.1759999999999999, 0.177, 0.166, \ 0.1459999999999999, 0.116, 0.08200000000000001, 0.049, 0.01799999999999999, -0.005, -0.019, -0.025, -0.025, -0.02199999999999999, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0.112, 0.134, 0.15, 0.154, 0.1469999999999999, 0.129, 0.103, 0.07299999999999999, 0.042, 0.015, -0.004, -0.015, -0.01799999999999999, \ -0.014, -0.008, 0, 0, 0, 0, 0, 0, 0, 0}, {0.0661, 0.09510000000000001, 0.1191, 0.1350999999999999, 0.1421, 0.1370999999999999, 0.1211, 0.0981, 0.06809999999999999, \ 0.04009999999999999, 0.015, -0.003, -0.01199999999999999, -0.013, -0.008, -0.001, 0, 0, 0, 0, \ 0, 0, 0}, {0.027, 0.05899999999999999, 0.08799999999999998, 0.114, 0.131, \ 0.139, 0.134, 0.1189999999999999, 0.095, 0.067, 0.039, 0.015, -0.002, -0.01099999999999999, -0.01099999999999999, -0.006, 0.003, 0, 0, 0, 0, \ 0, 0}, {0.001, 0.027, 0.05899999999999999, 0.08899999999999998, 0.114, 0.132, \ 0.138, 0.134, 0.1179999999999999, 0.09599999999999999, 0.068, 0.039, 0.015, \ -0.003, -0.01099999999999999, -0.01199999999999999, -0.006, 0.002, 0, 0, 0, 0, \ 0}, {-0.015, 0.005, 0.031, 0.06, 0.09, 0.116, 0.133, 0.14, 0.135, 0.1199999999999999, 0.09599999999999999, 0.068, 0.039, 0.015, -0.003, -0.01099999999999999, -0.013, -0.007, 0.001, 0, 0, 0, 0}, {-0.021, -0.01, 0.008, 0.034, 0.064, 0.094, 0.118, 0.136, 0.14, 0.137, \ 0.12, 0.097, 0.068, 0.039, 0.014, -0.003, -0.013, -0.013, -0.007, -0.002, 0, 0, 0}, {-0.019, -0.017, -0.007, 0.011, 0.037, 0.067, 0.095, 0.112, 0.137, 0.143, \ 0.138, 0.122, 0.097, 0.069, 0.04, 0.014, -0.005, -0.014, -0.015, -0.01, -0.003, 0, 0}, \ {-0.011, -0.016, -0.015, -0.005, 0.013, 0.039, 0.068, 0.097, 0.122, \ 0.138, 0.144, 0.138, 0.122, 0.097, 0.068, 0.039, 0.013, -0.005, -0.015, -0.016, \ -0.011, -0.004, 0}, {-0.004, -0.011, -0.016, -0.015, -0.005, 0.013, 0.039, 0.068, 0.097, \ 0.122, 0.138, 0.148, 0.138, 0.122, 0.097, 0.068, 0.039, 0.013, -0.005, -0.015, -0.016, -0.011, \ -0.004}}; \ \>", "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Definition of the exported functions", "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell[TextData[StyleBox["HendersonTrendExtraction[]", FontFamily->"Courier"]], "Subsubsection"], Cell[TextData[{ "Options[", StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "]={DataFrequency\[Rule]\"Monthly\",SeasonalityAveraging\[Rule] 3}" }], "Input", InitializationCell->True], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{ RowBox[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "[", \(y : {__?NumericQ}, order_Integer, opts___Rule\), "]"}], "/;", " ", "\n", " ", \(\((order == 5\ || \ order == 7\ || \ order == 9\ || \ order == 13\ || \ order == 15\ || \ order == 17\n || \ order == 23\ )\)\ && \ Length[y] > \ \((order + 1)\)\)}], " ", ":=", "\n", RowBox[{"With", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"seasave", "=", RowBox[{ \(SeasonalityAveraging\ /. \ {opts}\), " ", "/.", " ", RowBox[{"Options", "[", StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "]"}]}]}], ",", " ", "\n", "\t", RowBox[{"freq", "=", RowBox[{"Switch", "[", RowBox[{ RowBox[{\(DataFrequency /. {opts}\), "/.", RowBox[{"Options", "[", StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "]"}]}], ",", " ", \("\"\), ",", " ", "12", ",", " ", \("\"\), " ", ",", "4", ",", " ", \("\"\), ",", " ", "52", ",", " ", \("\"\), ",", " ", "365", ",", "Monthly", ",", " ", "12", ",", " ", "Quarterly", " ", ",", "4", ",", " ", "Weekly", ",", " ", "52", ",", " ", "Daily", ",", " ", "365", ",", " ", "_Integer", ",", " ", RowBox[{"Abs", "[", RowBox[{\(DataFrequency /. {opts}\), "/.", RowBox[{"Options", "[", StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "]"}]}], "]"}], ",", " ", "_", ",", " ", "\n", "\t\t", RowBox[{ RowBox[{"Message", "[", RowBox[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "::", "badfreq"}], "]"}], ";", "$Failed"}]}], "]"}]}]}], "}"}], ",", "\n", \(( HendersonMovingAverage[ Drop[Drop[y, Floor[\((freq - 1 + \((seasave*freq)\) - 1)\)/2]], \(-Ceiling[\((freq - 1 + \((seasave*freq)\) - 1)\)/2]\)]\ - \ MovingAverage[ Drop[Drop[y, Floor[\((freq - 1)\)/2]], \(-Ceiling[\((freq - 1)\)/2]\)]\ - MovingAverage[y, freq], seasave\ *\ freq], \ order]) \)}], "]"}]}], " ", "\n"}]], "Input", InitializationCell->True], Cell[BoxData[ RowBox[{ RowBox[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "[", \(y : {__?NumericQ}, order_Integer, opts___Rule\), "]"}], " ", ":=", RowBox[{"Message", "[", StyleBox[\(HendersonTrendExtraction::badord, order\), FontFamily->"Courier"], StyleBox["]", FontFamily->"Courier"]}]}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["HendersonMovingAverage[]", "Subsubsection", FontFamily->"Courier"], Cell[BoxData[ \(HendersonMovingAverage[y : {__Real}, order_Integer, opts___Rule] /; \ order \[LessEqual] 0\ := \ Message[HendersonMovingAverage::badord, order]\)], "Input", InitializationCell->True], Cell[BoxData[ \(HendersonMovingAverage[data : {__?NumericQ}, \ order_Integer] /; \ \n \ \ \((order == 5\ || \ order == 7\ || \ order == 9\ || \ order == 13\ || \ order == 15\ || \ order == 17\n || \ order == 23\ )\)\ && \ Length[data] > \ \((order + 1)\)\ := \n With[{n = Length[data]}, \n\ \ \ \ \ \ \ \ Join[\n\((HendersonStart[order].\((Take[data, order])\))\), \n \ \ \ \ \ \ \ \ LinearFilter[Drop[Rest[data], \(-1\)], \ HendersonMid[order]\ ], \n \ \ Reverse[HendersonEnd[order].\((Take[data, \(-order\)])\)]]\ ] \)], "Input", InitializationCell->True], Cell[BoxData[ \(HendersonMovingAverage[data : {__?NumericQ}, \ order_Integer] /; \ Length[data] < \ \((order + 1)\) := Message[HendersonMovingAverage::badord]\)], "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[TextData[StyleBox["HPFilter[]", "Input"]], "Subsubsection", InitializationCell->True], Cell[BoxData[ \(HPFilter[data_?VectorQ, lambda_Integer] := \n\t Module[{\[Tau], focs, taulist, simpleanswer}, \n\t\t With[{\[DoubleStruckCapitalT] = Length[data], \[Lambda] = N[lambda]}, \n\t\t\ttaulist\ = \ Table[\[Tau][t], {t, 1, \[DoubleStruckCapitalT]}]; \n focs = \tFlatten[ Join[{\(-2.\)\ data\[LeftDoubleBracket]1\[RightDoubleBracket]\ + 2.\ \[Tau][1] + 2.\ \[Lambda]\ \[Tau][1] - 4.\ \[Lambda]\ \[Tau][2] + 2.\ \[Lambda]\ \[Tau][3], \(-2.\)\ data\[LeftDoubleBracket]2\[RightDoubleBracket] - 4.\ \[Lambda]\ \[Tau][1] + 2.\ \[Tau][2] + 10.\ \[Lambda]\ \[Tau][2] - 8.\ \[Lambda]\ \[Tau][3] + 2.\ \[Lambda]\ \[Tau][4]}, \n Table[\t\(-2.\)\ \ data\[LeftDoubleBracket]t\[RightDoubleBracket] + 2.\ \[Lambda]\ \[Tau][t - 2] - 8.\ \[Lambda]\ \[Tau][t - 1] + 2.\ \[Tau][t] + 12.\ \[Lambda]\ \[Tau][t] - 8.\ \[Lambda]\ \[Tau][t + 1] + 2.\ \[Lambda]\ \[Tau][t + 2], {t, 3, \[DoubleStruckCapitalT] - 2}], \n \t\t{\(-2\)\ data\[LeftDoubleBracket]\[DoubleStruckCapitalT] - 1 \[RightDoubleBracket] + 2.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 3] - 8.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 2] + 2.\ \[Tau][\[DoubleStruckCapitalT] - 1] + 10.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 1] - 4.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT]], 2.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 2] - 4.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 1] + 2.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT]]}]]; \n \t\t\tfocs = Thread[focs == 0]; \n\t\t simpleanswer = Solve[focs, taulist]; \n\t\t Flatten[Expand[N[taulist /. simpleanswer]]]\n\t\t\t\t\t]]\)], "Input", PageWidth->PaperWidth, InitializationCell->True, AspectRatioFixed->True], Cell[BoxData[ \(HPFilter[data_?VectorQ, lambda_Real] := \n\t Module[{\[Tau], focs, taulist, simpleanswer}, \n\t\t With[{\[DoubleStruckCapitalT] = Length[data], \[Lambda] = N[lambda]}, \n\t\t\ttaulist\ = \ Table[\[Tau][t], {t, 1, \[DoubleStruckCapitalT]}]; \n focs = \tFlatten[ Join[{\(-2.\)\ data\[LeftDoubleBracket]1\[RightDoubleBracket]\ + 2.\ \[Tau][1] + 2.\ \[Lambda]\ \[Tau][1] - 4.\ \[Lambda]\ \[Tau][2] + 2.\ \[Lambda]\ \[Tau][3], \(-2.\)\ data\[LeftDoubleBracket]2\[RightDoubleBracket] - 4.\ \[Lambda]\ \[Tau][1] + 2.\ \[Tau][2] + 10.\ \[Lambda]\ \[Tau][2] - 8.\ \[Lambda]\ \[Tau][3] + 2.\ \[Lambda]\ \[Tau][4]}, \n Table[\t\(-2.\)\ \ data\[LeftDoubleBracket]t\[RightDoubleBracket] + 2.\ \[Lambda]\ \[Tau][t - 2] - 8.\ \[Lambda]\ \[Tau][t - 1] + 2.\ \[Tau][t] + 12.\ \[Lambda]\ \[Tau][t] - 8.\ \[Lambda]\ \[Tau][t + 1] + 2.\ \[Lambda]\ \[Tau][t + 2], {t, 3, \[DoubleStruckCapitalT] - 2}], \n \t\t{\(-2\)\ data\[LeftDoubleBracket]\[DoubleStruckCapitalT] - 1 \[RightDoubleBracket] + 2.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 3] - 8.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 2] + 2.\ \[Tau][\[DoubleStruckCapitalT] - 1] + 10.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 1] - 4.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT]], 2.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 2] - 4.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT] - 1] + 2.\ \[Lambda]\ \[Tau][\[DoubleStruckCapitalT]]}]]; \n \t\t\tfocs = Thread[focs == 0]; \n\t\t simpleanswer = Solve[focs, taulist]; \n\t\t Flatten[Expand[N[taulist /. simpleanswer]]]\n\t\t\t\t\t]]\)], "Input", PageWidth->PaperWidth, InitializationCell->True, AspectRatioFixed->True], Cell[BoxData[ \(HPFilter[\((data_)\)?MatrixQ, lambda_] := \n\t \(HPFilter[#, lambda]&\)\ /@\ data\)], "Input", InitializationCell->True], Cell[BoxData[ \(HPFilter[data_List, lambda_] := \n\t \(HPFilter[#, lambda]&\)\ /@\ data\)], "Input", InitializationCell->True] }, Closed]] }, 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[ HPFilter,hendersonweights,HendersonMovingAverage,HendersonStart,\ HendersonEnd,HendersonMid ]\ \>", "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["This loads the package ", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["This generates some test AR(1) data", "Text"], Cell[BoxData[ \(\(testdata = NestList[0.1\ + 0.9\ #\ + 3\ \ Random[]\ &, 12., 200]; \)\)], "Input"], Cell[BoxData[ \(Block[{graph1, graph2}, \n\t graph1\ = ListPlot[HPFilter[testdata, 1600], PlotJoined -> True, DisplayFunction \[Rule] Identity, PlotStyle \[Rule] Hue[0.01]]; \n \tgraph2\ = \ ListPlot[testdata, DisplayFunction \[Rule] Identity, PlotStyle \[Rule] GrayLevel[0.6]]; \n\t Show[graph1, graph2, DisplayFunction \[Rule] $DisplayFunction]] // Timing\)], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"Show", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"ListPlot", "[", RowBox[{ RowBox[{ StyleBox["HendersonTrendExtraction", FontFamily->"Courier"], "[", \(testdata, 13\), "]"}], ",", \(PlotJoined \[Rule] True\), ",", \(DisplayFunction \[Rule] Identity\)}], "]"}], ",", "\n", "\t\t", RowBox[{"ListPlot", "[", RowBox[{ RowBox[{"Drop", "[", RowBox[{ RowBox[{ StyleBox["HendersonMovingAverage", FontFamily->"Courier"], "[", \(testdata, 13\), "]"}], ",", "23"}], "]"}], ",", \(PlotStyle \[Rule] Hue[0]\), ",", \(PlotJoined \[Rule] True\), ",", \(DisplayFunction \[Rule] Identity\)}], "]"}]}], "}"}], ",", \(DisplayFunction \[Rule] $DisplayFunction\)}], "]"}], "//", "Timing"}]], "Input"], Cell[BoxData[ \(Show[ ListPlot[testdata, PlotJoined \[Rule] True, DisplayFunction \[Rule] Identity], ListPlot[HendersonMovingAverage[testdata, 17], PlotJoined \[Rule] True, PlotStyle \[Rule] {AbsoluteThickness[3.5], GrayLevel[0.7]}, DisplayFunction \[Rule] Identity], DisplayFunction \[Rule] $DisplayFunction] // Timing\)], "Input"] }, Open ]] }, Open ]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 1152}, {0, 850}}, AutoGeneratedPackage->Automatic, CellGrouping->Automatic, WindowSize->{1036, 789}, WindowMargins->{{34, Automatic}, {Automatic, 19}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, 128}}, ShowCellLabel->True, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, Magnification->1.25, MacintoshSystemPageSetup->"\<\ 00<0001804P000000ad2" ] (*********************************************************************** 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, 63, 1, 122, "Title"], Cell[1797, 54, 154, 4, 57, "Subsubtitle"], Cell[1954, 60, 222, 6, 36, "Text"], Cell[CellGroupData[{ Cell[2201, 70, 28, 0, 62, "Section"], Cell[CellGroupData[{ Cell[2254, 74, 30, 0, 49, "Subsubsection"], Cell[2287, 76, 70, 1, 36, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2394, 82, 31, 0, 49, "Subsubsection"], Cell[2428, 84, 29, 0, 36, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2494, 89, 32, 0, 49, "Subsubsection"], Cell[2529, 91, 215, 6, 36, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[2781, 102, 34, 0, 49, "Subsubsection"], Cell[2818, 104, 242, 6, 93, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3097, 115, 41, 0, 49, "Subsubsection"], Cell[3141, 117, 19, 0, 36, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3197, 122, 101, 4, 49, "Subsubsection"], Cell[3301, 128, 19, 0, 86, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[3357, 133, 32, 0, 31, "Subsubsection"], Cell[3392, 135, 163, 3, 55, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[3592, 143, 33, 0, 31, "Subsubsection"], Cell[3628, 145, 102, 3, 36, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3767, 153, 31, 0, 49, "Subsubsection"], Cell[3801, 155, 640, 9, 93, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[4478, 169, 33, 0, 49, "Subsubsection"], Cell[4514, 171, 169, 3, 36, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[4720, 179, 35, 0, 49, "Subsubsection"], Cell[4758, 181, 182, 4, 36, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[4977, 190, 35, 0, 49, "Subsubsection"], Cell[5015, 192, 981, 19, 113, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[6033, 216, 37, 0, 31, "Subsubsection"], Cell[6073, 218, 87, 2, 36, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[6209, 226, 56, 1, 62, "Section", InitializationCell->True], Cell[6268, 229, 123, 3, 36, "Text", InitializationCell->True], Cell[CellGroupData[{ Cell[6416, 236, 102, 1, 55, "Subsection", InitializationCell->True], Cell[6521, 239, 123, 3, 32, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[6681, 247, 122, 3, 55, "Subsection", InitializationCell->True], Cell[6806, 252, 251, 5, 49, "Input", InitializationCell->True], Cell[7060, 259, 535, 12, 83, "Input", InitializationCell->True], Cell[7598, 273, 370, 7, 83, "Input", InitializationCell->True], Cell[7971, 282, 214, 5, 49, "Input", InitializationCell->True], Cell[8188, 289, 221, 5, 49, "Input", InitializationCell->True], Cell[8412, 296, 211, 5, 49, "Input", InitializationCell->True], Cell[8626, 303, 364, 8, 66, "Input", InitializationCell->True], Cell[8993, 313, 309, 7, 49, "Input", InitializationCell->True], Cell[9305, 322, 264, 5, 66, "Input", InitializationCell->True], Cell[9572, 329, 329, 6, 66, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[9938, 340, 89, 1, 55, "Subsection", InitializationCell->True], Cell[10030, 343, 239, 6, 49, "Input", InitializationCell->True], Cell[10272, 351, 258, 6, 49, "Input", InitializationCell->True], Cell[10533, 359, 281, 7, 49, "Input", InitializationCell->True], Cell[10817, 368, 258, 6, 49, "Input", InitializationCell->True], Cell[11078, 376, 228, 5, 49, "Input", InitializationCell->True], Cell[11309, 383, 165, 4, 49, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[11523, 393, 61, 1, 62, "Section", InitializationCell->True], Cell[11587, 396, 131, 3, 36, "Text"], Cell[CellGroupData[{ Cell[11743, 403, 97, 1, 55, "Subsection", InitializationCell->True], Cell[11843, 406, 65, 1, 32, "Input", InitializationCell->True] }, Open ]], Cell[11923, 410, 76, 1, 55, "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell[12024, 415, 120, 3, 55, "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell[12169, 422, 69, 1, 49, "Subsubsection", InitializationCell->True], Cell[12241, 425, 246, 5, 52, "Input", InitializationCell->True], Cell[12490, 432, 1335, 26, 242, "Input", InitializationCell->True], Cell[13828, 460, 431, 8, 128, "Input", InitializationCell->True], Cell[14262, 470, 628, 11, 166, "Input", InitializationCell->True], Cell[14893, 483, 1105, 20, 242, "Input", InitializationCell->True], Cell[16001, 505, 1944, 32, 318, "Input", InitializationCell->True], Cell[17948, 539, 2588, 40, 451, "Input", InitializationCell->True], Cell[20539, 581, 2224, 41, 593, "Input", InitializationCell->True], Cell[22766, 624, 5378, 109, 1239, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[28193, 739, 86, 1, 55, "Subsection", InitializationCell->True], Cell[CellGroupData[{ Cell[28304, 744, 96, 1, 49, "Subsubsection"], Cell[28403, 747, 207, 6, 32, "Input", InitializationCell->True], Cell[28613, 755, 3065, 59, 261, "Input", InitializationCell->True], Cell[31681, 816, 402, 10, 52, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[32120, 831, 74, 1, 49, "Subsubsection"], Cell[32197, 834, 221, 4, 52, "Input", InitializationCell->True], Cell[32421, 840, 662, 11, 166, "Input", InitializationCell->True], Cell[33086, 853, 219, 4, 52, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[33342, 862, 92, 1, 49, "Subsubsection", InitializationCell->True], Cell[33437, 865, 2255, 39, 356, "Input", InitializationCell->True], Cell[35695, 906, 2252, 39, 356, "Input", InitializationCell->True], Cell[37950, 947, 148, 3, 52, "Input", InitializationCell->True], Cell[38101, 952, 138, 3, 52, "Input", InitializationCell->True] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[38288, 961, 73, 1, 34, "Subsection", InitializationCell->True], Cell[38364, 964, 51, 1, 32, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[38464, 971, 53, 1, 62, "Section", InitializationCell->True], Cell[38520, 974, 76, 0, 36, "Text"], Cell[CellGroupData[{ Cell[38621, 978, 73, 1, 55, "Subsection", InitializationCell->True], Cell[38697, 981, 155, 4, 32, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[38889, 990, 73, 1, 55, "Subsection", InitializationCell->True], Cell[38965, 993, 58, 1, 32, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[39072, 1000, 34, 0, 62, "Section"], Cell[39109, 1002, 39, 0, 36, "Text"], Cell[39151, 1004, 68, 1, 33, "Input"], Cell[39222, 1007, 51, 0, 36, "Text"], Cell[39276, 1009, 110, 2, 33, "Input"], Cell[39389, 1013, 455, 9, 109, "Input"], Cell[39847, 1024, 1142, 26, 109, "Input"], Cell[40992, 1052, 406, 8, 109, "Input"] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)