

    \filetitle{hpf}{Hodrick-Prescott filter with tunes}{tseries/hpf}

	\paragraph{Syntax}
 
 \begin{verbatim}
 [T,C] = hpf(X)
 [T,C] = hpf(X,RANGE,...)
 \end{verbatim}
 \paragraph{Syntax with output arguments swapped}
 
 \begin{verbatim}
 [C,T] = hpf2(X)
 [C,T] = hpf2(X,RANGE,...)
 \end{verbatim}
 \paragraph{Input arguments}
 
 \begin{itemize}
 \item
   \texttt{X} {[} tseries {]} - Input tseries object that will be
   filtered.
 \item
   \texttt{RANGE} {[} numeric {]} - Date range on which the input data
   will be filtered; \texttt{RANGE} can be \texttt{Inf},
   \texttt{{[}startdata,Inf{]}}, or \texttt{{[}-Inf,enddate{]}}; if not
   specifired, \texttt{Inf} (i.e.~the entire available range of the input
   series) is used.
 \end{itemize}
 \paragraph{Output arguments}
 
 \begin{itemize}
 \item
   \texttt{T} {[} tseries {]} - Lower-frequency (trend) component.
 \item
   \texttt{C} {[} tseries {]} - Higher-frequency (cyclical) component.
 \end{itemize}
 \paragraph{Options}
 
 \begin{itemize}
 \item
   \texttt{'lambda='} {[} numeric \textbar{}
   \emph{\texttt{100 freq\^{}2}} {]} - Smoothing parameter; needs to be
   specified for tseries objects with indeterminate frequency.
 \item
   \texttt{'level='} {[} tseries {]} - Hard tunes on the level of the
   trend.
 \item
   \texttt{'change='} {[} tseries {]} - Hard tunes on the change of the
   trend.
 \item
   \texttt{'log='} {[} \texttt{true} \textbar{} \emph{\texttt{false}} {]}
   - Logarithmise the data before filtering, de-logarithmise afterwards.
 \end{itemize}
 \paragraph{Description}
 
 \subparagraph{Design of the optimisation problem}
 
 The \texttt{hpf} function solves the following constrained optimisation
 problem: \[
 \min_{\bar y_t} \lambda \sum_t 
 \left( \Delta \bar y_t - \Delta \bar y_t \right)^2
 + \sum_{t\in\Omega} \left( \bar y_t - y_t \right)^2,
 \] where \texttt{\textbackslash{}Delta} is the first-difference
 operator, \texttt{\textbackslash{}lambda} is the smoothing parameter,
 \texttt{\textbackslash{}bar y\_t} is the computed trend, \texttt{y\_t}
 are the actual data, and \texttt{\textbackslash{}Omega} is the set of
 periods in which the observations are available, subject to
 
 \begin{itemize}
 \item
   constraints on the level of the trend: \[
   \bar y_\tau = a_\tau, \quad \tau \in \Sigma_1,
   \] where \texttt{a\_\textbackslash{}tau} are the user-specified hard
   tunes, and \texttt{\textbackslash{}Sigma\_1} is the set of periods in
   which the user has imposed constraints on the level of the trend;
 \item
   constraints on the change in trend: \[
   \Delta \bar y_\tau = b_\tau, \quad \tau \in \Sigma_2.
   \] where \texttt{b\_\textbackslash{}tau} are the user-specified hard
   tunes and \texttt{\textbackslash{}Sigma\_2} is the set of periods in
   which the user has imposed constraints on the change in the trend.
 \end{itemize}
 \subparagraph{Default smoothing parameters}
 
 If the user does not specify the smoothing parameter using the
 \texttt{'lambda='} option, a default value is used. The default value is
 based on the date frequency of the input time series, and is calculated
 as $\lambda = 100 \cdot f^2$, where $f$ is the frequency (yearly=1,
 half-yearly=2, quarterly=4, bi-monthly=6, monthly=12). This gives the
 following default values:
 
 \begin{itemize}
 \item
   100 for yearly time series,
 \item
   400 for half-yearly time series,
 \item
   1600 for quarterly time series,
 \item
   3600 for bi-monthly time series,
 \item
   14400 for monthly time series.
 \end{itemize}
 Note that there is no default value for data with indeterminate or daily
 frequency. For these time series, you must supply the \texttt{'lambda='}
 option.
 
 \paragraph{Example}


