Description Usage Arguments Details Value Author(s) References Examples

This function runs through an iterative process in order to find the optimal bandwidth for the nonparametric estimation of the first or second derivative of the trend in an equidistant time series (with short-memory errors) and subsequently employs the obtained bandwidth via local polynomial regression.

1 2 3 4 5 6 7 8 |

`y` |
a numeric vector that contains the time series ordered from past to present. | ||||||||||

`d` |
an integer | ||||||||||

`mu` |
an integer
| ||||||||||

`pp` |
an integer | ||||||||||

`bStart.p` |
a numeric object that indicates the starting value of the
bandwidth for the iterative process for the calculation of | ||||||||||

`bStart` |
a numeric object that indicates the starting value of the
bandwidth for the iterative process; should be |

The trend's derivative is estimated based on the additive nonparametric regression model for an equidistant time series

*y_t = m(x_t) + ε_t,*

where *y_t* is the observed time series, *x_t* is the rescaled time
on the interval *[0, 1]*, *m(x_t)* is a smooth and deterministic
trend function and *ε_t* are stationary errors with
*E(ε_t) = 0* and short-range dependence (see also Beran and Feng,
2002). With this function, the first or second derivative of *m(x_t)*
can be estimated without a parametric model assumption for the error series.

The iterative-plug-in (IPI) algorithm, which numerically minimizes the Asymptotic Mean Squared Error (AMISE), was proposed by Feng, Gries and Fritz (2020).

Define *I[m^(k)] =
int_[c_b]^[d_b] {m^(k)}^2 dx*, *β_(ν, k) = int_[-1]^[1] u^k K_(ν, k)(u) du*
and *R(K) = int_[-1]^[1]
{K_(ν, k)}^2 du*, where *p* is the order of the polynomial,
*k = p + 1* is the order of the asymptotically equivalent kernel,
*ν* is the order of the trend function's derivative, *0 ≤ c_b < d_b ≤ 1*, *c_f* is the variance factor and
*K_(ν, k)(u)* the *k*-th order equivalent kernel
obtained for the estimation of *m^(ν)* in the interior.
*m^(ν)* is the *ν*-th order derivative (*ν = 0,
1, 2, ...*) of the nonparametric trend.

Furthermore, we define

*C_1 =
[I[m^(k)]{β_(ν, k)}^2] / (k!)^2*

and

*C_2 =
2π(d_b - c_b)R(K)c_f / (nh^[2ν + 1])*

with *h* being the bandwidth and *n* being the number of
observations. The AMISE is then

*AMISE(h) = h^[2(k - ν)] C_1 +
C_2.*

The variance factor *c_f* is first obtained from a pilot-estimation of
the time series' nonparametric trend (*ν = 0*) with polynomial order
*p_p*. The estimate is then plugged into the iterative procedure for
estimating the first or second derivative (*ν = 1* or *ν = 2*).
For further details on the asymptotic theory or the algorithm, we refer the
user to Feng, Fritz and Gries (2020) and Feng et al. (2019).

The function itself is applicable in the following way: Based on a data input
`y`

, an order of polynomial `pp`

for the variance factor estimation
procedure, a starting value for the relative bandwidth `bStart.p`

in the
variance factor estimation procedure, a kernel function defined by the
smoothness parameter `mu`

and a starting value for the relative
bandwidth `bStart`

in the bandwidth estimation procedure, an optimal
bandwidth is numerically calculated for the trend's derivative of order
`d`

. In fact, aside from the input vector `y`

, every argument has a
default setting that can be adjusted for the individual case. However, it is
recommended to initially use the default values for the estimation of the
first derivative and adjust the argument `d`

to `d = 2`

for the
estimation of the second derivative. Following Feng, Gries and Fritz (2020),
the initial bandwidth does not affect the resulting optimal bandwidth in
theory. However in practice, local minima of the AMISE can influence the
results. Therefore, the default starting bandwidth is set to `0.15`

, the
suggested starting bandwidth by Feng, Gries and Fritz (2020) for the
data-driven estimation of the first derivative. The recommended initial
bandwidth for the second derivative, however, is `0.2`

and not
`0.15`

. Thus, if the algorithm does not give suitable results
(especially for `d = 2`

), the adjustment of the initial bandwidth might
be a good starting point. Analogously, the default starting bandwidth for the
trend estimation for the variance factor is `bStart.p = 0.15`

, although
according to Feng, Gries and Fritz (2020), `bStart.p = 0.1`

is suggested
for `pp = 1`

and `bStart.p = 0.2`

for `pp = 3`

. The default is
therefore a compromise between the two suggested values. For more specific
information on the input arguments consult the section *Arguments*.

After the bandwidth estimation, the nonparametric derivative of the series is calculated with respect to the obtained optimal bandwidth by means of a local polynomial regression. The output object is then a list that contains, among other components, the original time series, the estimates of the derivative and the estimated optimal bandwidth.

The default print method for this function delivers key numbers such as
the iteration steps and the generated optimal bandwidth rounded to the fourth
decimal. The exact numbers and results such as the estimated nonparametric
trend series are saved within the output object and can be addressed via the
`$`

sign.

NOTE:

The estimates are obtained for the rescaled time points on the interval
*[0, 1]*. Therefore, the estimated derivatives might not reflect the
derivatives for the actual time points. To rescale them, we refer the
user to the `rescale`

function of the `smoots`

package.

With package version 1.1.0, this function implements C++ code by means
of the `Rcpp`

and
`RcppArmadillo`

packages for
better performance.

The function returns a list with different components:

- b0
the optimal bandwidth chosen by the IPI-algorithm.

- bStart
the starting bandwidth for the local polynomial regression based derivative estimation procedure; input argument.

- bStart.p
the starting bandwidth for the nonparametric trend estimation that leads to the variance factor estimate; input argument.

- bvc
indicates whether an enlarged bandwidth was used for the variance factor estimation or not; it is always set to

`"Y"`

(yes) for this function.- cf0
the estimated variance factor; in contrast to the definitions given in the

*Details*section, this object actually contains an estimated value of*2π c_f*, i.e. it corresponds to the estimated sum of autocovariances.- InfR
the inflation rate setting.

- iterations
the bandwidths of the single iterations steps

- Mcf
the estimation method for the variance factor estimation; it is always estimated nonparametrically (

`"NP"`

) within this function.- mu
the smoothness parameter of the second order kernel; input argument.

- n
the number of observations.

- niterations
the total number of iterations until convergence.

- orig
the original input series; input argument.

- p
the order of polynomial for the local polynomial regression used within derivative estimation procedure.

- pp
the order of polynomial for the local polynomial regression used in the variance factor estimation; input argument.

- v
the considered order of the trend's derivative; input argument

`d`

.- ws
the weighting system matrix used within the local polynomial regression; this matrix is a condensed version of a complete weighting system matrix; in each row of

`ws`

, the weights for conducting the smoothing procedure at a specific observation time point can be found; the first*[nb + 0.5]*rows, where*n*corresponds to the number of observations,*b*is the bandwidth considered for smoothing and*[.]*denotes the integer part, contain the weights at the*[nb + 0.5]*left-hand boundary points; the weights in row*[nb + 0.5] + 1*are representative for the estimation at all interior points and the remaining rows contain the weights for the right-hand boundary points; each row has exactly*2[nb + 0.5] + 1*elements, more specifically the weights for observations of the nearest*2[nb + 0.5] + 1*time points; moreover, the weights are normalized, i.e. the weights are obtained under consideration of the time points*x_t = t/n*, where*t = 1, 2, ..., n*.- ye
the nonparametric estimates of the derivative for the rescaled time points on the interval

*[0, 1]*.

Yuanhua Feng (Department of Economics, Paderborn University),

Author of the Algorithms

Website: https://wiwi.uni-paderborn.de/en/dep4/feng/Dominik Schulz (Research Assistant) (Department of Economics, Paderborn University),

Package Creator and Maintainer

Feng, Y., Gries, T. and Fritz, M. (2020). Data-driven local polynomial for the trend and its derivatives in economic time series. Journal of Nonparametric Statistics, 32:2, 510-533.

Feng, Y., Gries, T., Letmathe, S. and Schulz, D. (2019). The smoots package in R for semiparametric modeling of trend stationary time series. Discussion Paper. Paderborn University. Unpublished.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
# Logarithm of test data
test_data <- gdpUS
y <- log(test_data$GDP)
t <- seq(from = 1947, to = 2019.25, by = 0.25)
# Applied dsmooth function for the trend's first derivative
result_d <- dsmooth(y, d = 1, mu = 1, pp = 1, bStart.p = 0.1, bStart = 0.15)
estim <- result_d$ye
# Plot of the results
plot(t, estim, xlab = "Year", ylab = "First derivative", type = "l",
main = paste0("Estimated first derivative of the trend for log-quarterly ",
"US-GDP, Q1 1947 - Q2 2019"), cex.axis = 0.8, cex.main = 0.8,
cex.lab = 0.8, bty = "n")
# Print result
result_d
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.