dsmoothlm {esemifar} | R Documentation |
Data-driven Local Polynomial for the Trend's Derivatives in Equidistant Time Series
Description
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 long-memory errors) and subsequently employs the obtained bandwidth via local polynomial regression.
Usage
dsmoothlm(
y,
d = c(1, 2),
pmin = c(0, 1, 2, 3, 4, 5),
pmax = c(0, 1, 2, 3, 4, 5),
qmin = c(0, 1, 2, 3, 4, 5),
qmax = c(0, 1, 2, 3, 4, 5),
mu = c(0, 1, 2, 3),
mu.p = c(0, 1, 2, 3),
pp = c(1, 3),
bStart.p = 0.15,
InfR.p = c("Opt", "Nai", "Var")
)
Arguments
y |
a numeric vector that contains the time series ordered from past to present. | ||||||||||
d |
an integer | ||||||||||
pmin |
an integer value | ||||||||||
pmax |
an integer value | ||||||||||
qmin |
an integer value | ||||||||||
qmax |
an integer value | ||||||||||
mu |
an integer | ||||||||||
mu.p |
an integer
| ||||||||||
pp |
an integer | ||||||||||
bStart.p |
a numeric object that indicates the starting value of the
bandwidth for the iterative process to obtain initial estimates for | ||||||||||
InfR.p |
a character object that represents the inflation
rate in the form |
Details
The trend is estimated based on the additive nonparametric regression model for an equidistant time series
y_t = m(x_t) + \epsilon_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 \epsilon_t
are stationary errors with
E(\epsilon_t) = 0
and is assumed to follow a FARIMA(p, d, q
)
model (see also Beran and Feng, 2002).
The iterative-plug-in (IPI) algorithm, which numerically minimizes the Asymptotic Mean Squared Error (AMISE), is based on the proposal of Beran and Feng (2002a).
The variance factor c_f
, the long memory parameter d
and the
starting bandwidth b0
are first obtained from a pilot-estimation of
the time series' nonparametric trend (\nu = 0
) with polynomial order
p_p
. The estimate is then plugged into the iterative procedure for
estimating the first or second derivative (\nu = 1
or \nu = 2
).
For further details on the asymptotic theory or the algorithm, we refer the
user to Letmathe, Beran and Feng (2023).
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 and a kernel function defined by the
smoothness parameter mu
, 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.
The initial bandwidth does not affect the resulting optimal bandwidth in
theory. However in practice, local minima of the AMISE can influence the
results. 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.
Value
The function returns a list with different components:
- b0
the optimal bandwidth chosen by the IPI-algorithm.
- bStart.p
the starting bandwidth for the nonparametric trend estimation that leads to the initial estimates; input argument.
- cf0
the estimated variance factor.
- InfR.p
the inflation rate setting.
- iterations
the bandwidths of the single iterations steps
- mu.p
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 pilot 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, wheren
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 exactly2[nb + 0.5] + 1
elements, more specifically the weights for observations of the nearest2[nb + 0.5] + 1
time points; moreover, the weights are normalized, i.e. the weights are obtained under consideration of the time pointsx_t = t/n
, wheret = 1, 2, ..., n
.- ye
the nonparametric estimates of the derivative.
Author(s)
Yuanhua Feng (Department of Economics, Paderborn University),
Author of the Algorithms
Website: https://wiwi.uni-paderborn.de/en/dep4/feng/Sebastian Letmathe (Scientific Employee) (Department of Economics, Paderborn University),
Package Creator and MaintainerDominik Schulz (Scientific Employee) (Department of Economics, Paderborn University),
Author
References
Letmathe, S., Beran, J. and Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods: 1-13.
Examples
# Logarithm of test data
test_data <- gdpG7
y <- log(test_data$gdp)
n <- length(y)
t <- seq(from = 1962, to = 2020, length.out = n)
# Applied dsmooth function for the trend's first derivative
result_d <- dsmoothlm(y, d = 1, pp = 1, pmax = 1, qmax = 1, InfR.p = "Opt")
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 ",
"G7-GDP, Q1 1962 - Q4 2019"), cex.axis = 0.8, cex.main = 0.8,
cex.lab = 0.8, bty = "n")
# Print result
result_d
# The main function "dsmoothlm"------------------------------------------