Description Usage Arguments Details Value Author(s) References Examples
This function estimates the nonparametric trend function in an equidistant time series with NadarayaWatson kernel regression.
1 
y 
a numeric vector that contains the time series data ordered from past to present.  
mu 
an integer
 
b 
a real number 0 <  
bb 
can be set to

The trend 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.
This function is part of the package smoots
and is used for
the estimation of trends in equidistant time series. The applied method
is a kernel regression with arbitrarily selectable second order
kernel, relative bandwidth and boundary method. Especially the chosen
bandwidth has a strong impact on the final result and has thus to be
selected carefully. This approach is not recommended by the authors of this
package.
The output object is a list with different components:
the chosen (relative) bandwidth; input argument.
the chosen bandwidth option at the boundaries; input argument.
the chosen smoothness parameter for the second order kernel; input argument.
the number of observations.
the original input series; input argument.
a vector with the estimated residual series.
a vector with the estimates of the nonparametric trend.
Yuanhua Feng (Department of Economics, Paderborn University),
Author of the Algorithms
Website: https://wiwi.unipaderborn.de/en/dep4/feng/
Dominik Schulz (Research Assistant) (Department of Economics, Paderborn
University),
Package Creator and Maintainer
Feng, Y. (2009). Kernel and Locally Weighted Regression. Verlag für Wissenschaft und Forschung, Berlin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  # Logarithm of test data
test_data < gdpUS
y < log(test_data$GDP)
#Applied knmooth function for the trend with two different bandwidths
trend1 < knsmooth(y, mu = 1, b = 0.28, bb = 1)$ye
trend2 < knsmooth(y, mu = 1, b = 0.05, bb = 1)$ye
# Plot of the results
t < seq(from = 1947, to = 2019.25, by = 0.25)
plot(t, y, type = "l", xlab = "Year", ylab = "log(USGDP)", bty = "n",
lwd = 2,
main = "Estimated trend for logquarterly USGDP, Q1 1947  Q2 2019")
points(t, trend1, type = "l", col = "red", lwd = 1)
points(t, trend2, type = "l", col = "blue", lwd = 1)
legend("bottomright", legend = c("Trend (b = 0.28)", "Trend (b = 0.05)"),
fill = c("red", "blue"), cex = 0.6)
title(sub = expression(italic("Figure 1")), col.sub = "gray47",
cex.sub = 0.6, adj = 0)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.