# trendCast: Forecasting Function for Nonparametric Trend Functions In smoots: Nonparametric Estimation of the Trend and Its Derivatives in TS

## Description

Forecasting Function for Nonparametric Trend Functions

## Usage

 `1` ```trendCast(object, h = 1, np.fcast = c("lin", "const"), plot = FALSE, ...) ```

## Arguments

 `object` an object returned by either `msmooth`, `tsmooth`, `gsmooth` (with `v = 0`) or `knsmooth`. `h` the forecasting horizon; the values m(n + 1) to m(n + h) will be predicted; is set to `h = 1` by default; decimal numbers will be rounded off to integers. `np.fcast` the forecasting method; `np.fcast = "lin"` uses a linear extrapolation, whereas `np.fcast = "const"` uses the last fitted value of m(x_t) as a forecast; is set to `"lin"` by default. `plot` a logical value; if set to `TRUE`, a simple plot of the original time series, the local polynomial trend estimates as well as the predicted values is generated. `...` additional arguments for the standard plot function, e.g., `xlim`, `type`, ... ; arguments with respect to plotted graphs, e.g., the argument `col`, only affect the original series `X`; please note that in accordance with the argument `x` (lower case) of the standard plot function, an additional numeric vector with time points can be implemented via the argument `x` (lower case). `x` should be valid for the sample observations only, i.e. `length(x) == length(obj\$orig)` should be `TRUE`, as future time points will be calculated automatically.

## Details

This function is part of the `smoots` package and was implemented under version 1.1.0. The underlying theory is based on the additive nonparametric regression function

y_t = m(x_t) + ε_t,

where y_t is the observed time series with equidistant design, 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.

The purpose of this function is the forecasting of future values based on a nonparametric regression model. Following the proposition in Fritz et al. (2020), point predictions can be conducted separately for the nonparametric trend function m(x_t) and the stationary part ε_t. The sum of both forecasts is then the forecast of y_t. With this function, only the forecast with respect to m(x_t) is computable. Now assume that the variance of the error in the local polynomial forecasts is negligible when calculating the forecasting intervals. We define the forecast for time point n + k, k = 1, 2, ..., h, by

hat[m](x_[n + k]) = hat[m](x_n) + Dk * δ_m,

where δ_m is equal to hat[m](x_n) - hat[m](x_[n - 1]) and D is a dummy variable. If D = 1, a linear extrapolation is applied. For D = 0, hat[m](x_n) is the predicted value.

To make use of this function, an object of class `smoots` can be given as input. However, since the discussed approach is only valid for the estimated trend function, only objects created by `msmooth`, `tsmooth`, `knsmooth` and `link{gsmooth}`, if the trend was estimated, will be appropriate input objects.

With the input argument `h`, a positive integer can be given to the function that represents the forecasting horizon, i.e. how many future values are to be estimated. Via the argument `np.fcast` the value of the dummy variable D can be specified and thus the forecasting method. For `np.fcast = "lin"`, D = 1 is applied, whereas for `np.fcast = "const"`, D is set to 0.

By means of the argument `plot` that can be either set to the logical values `TRUE` or `FALSE`, a simple plot of the original series alongside the local polynomial estimates as well as the forecasted values can be either generated or suppressed.

The function always returns a vector of forecasted values ordered from n + 1 to n + h. Depending on the setting of the argument `plot`, a generic plot of the results may be generated. Furthermore, additional arguments of the standard plot function can be passed to this function as well to adjust the generated plot.

## Value

A numeric vector is always returned with the forecasted values. Depending on the setting for the argument plot, a generic plot might be created.

## Author(s)

• Yuanhua Feng (Department of Economics, Paderborn University),
Author of the Algorithms

• Dominik Schulz (Research Assistant) (Department of Economics, Paderborn University),
Package Creator and Maintainer

## References

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.

Feng, Y., Gries, T., Fritz, M., Letmathe, S. and Schulz, D. (2020). Diagnosing the trend and bootstrapping the forecasting intervals using a semiparametric ARMA. Discussion Paper. Paderborn University. Unpublished.

Fritz, M., Forstinger, S., Feng, Y., and Gries, T. (2020). Forecasting economic growth processes for developing economies. Unpublished.

## Examples

 ```1 2 3 4``` ```log_gdp <- log(smoots::gdpUS\$GDP) est <- msmooth(log_gdp) forecasts <- trendCast(est, h = 5, plot = TRUE) forecasts ```

smoots documentation built on Oct. 10, 2021, 1:09 a.m.