twoStepsBenchmark {disaggR} | R Documentation |
Regress and bends a time series with a lower frequency one
Description
twoStepsBenchmark bends a time series with a time series of a lower frequency. The procedure involved is a Prais-Winsten regression, then an additive Denton benchmark.
Therefore, the resulting time series is the sum of a regression fit and of a smoothed part. The smoothed part minimizes the sum of squares of its differences.
The resulting time series is equal to the low-frequency series after aggregation within the benchmark window.
Usage
twoStepsBenchmark(hfserie,lfserie,include.differenciation=FALSE,include.rho=FALSE,
set.coeff=NULL,set.const=NULL,
start.coeff.calc=NULL,end.coeff.calc=NULL,
start.benchmark=NULL,end.benchmark=NULL,
start.domain=NULL,end.domain=NULL,outliers=NULL,
...)
annualBenchmark(hfserie,lfserie,
include.differenciation=FALSE,include.rho=FALSE,
set.coeff=NULL,set.const=NULL,
start.coeff.calc=start(lfserie)[1L],
end.coeff.calc=end(lfserie)[1L],
start.benchmark=start(lfserie)[1L],
end.benchmark=end.coeff.calc[1L]+1L,
start.domain=start(hfserie),
end.domain=c(end.benchmark[1L]+2L,frequency(hfserie)),
outliers=NULL)
Arguments
hfserie |
the bended time series. It can be a matrix time series. |
lfserie |
a time series whose frequency divides the frequency of |
include.differenciation |
a boolean of length 1. If |
include.rho |
a boolean of length 1. If |
set.coeff |
an optional numeric, that allows the user to set the
regression coefficients instead of evaluating them.
If hfserie is not a matrix, set.coeff can be an unnamed numeric of length 1.
Otherwise, |
set.const |
an optional numeric of length 1, that sets the regression
constant.
The constant is actually an automatically added column to |
start.coeff.calc |
an optional start for the estimation of the
coefficients of the regression.
Should be a numeric of length 1 or 2, like a window for |
end.coeff.calc |
an optional end for the estimation of the coefficients
of the regression.
Should be a numeric of length 1 or 2, like a window for |
start.benchmark |
an optional start for |
end.benchmark |
an optional end for |
start.domain |
an optional for the output high-frequency series. It also
defines the smoothing window :
The low-frequency residuals will be extrapolated until they contain the
smallest low-frequency window that is around the high-frequency domain
window.
Should be a numeric of length 1 or 2, like a window for |
end.domain |
an optional end for the output high-frequency series. It
also defines the smoothing window :
The low-frequency residuals will be extrapolated until they contain the
smallest low-frequency window that is around the high-frequency domain
window.
Should be a numeric of length 1 or 2, like a window for |
outliers |
an optional named list of numeric vectors, whose pattern is
like
The outliers coefficients are evaluated though the regression process, like
any coefficient. Therefore, if any outlier is outside of the coefficient
calculation window, it should be fixed using |
... |
if the dots contain a cl item, its value overwrites the value of the returned call. This feature allows to build wrappers. |
Details
annualBenchmark is a wrapper of the main function, that applies more specifically to annual series, and changes the default window parameters to the ones that are commonly used by quarterly national accounts.
Value
twoStepsBenchark returns an object of class "twoStepsBenchmark
".
The function summary
can be used to obtain and print a summary of the
regression used by the benchmark.
The functions plot
and autoplot
(the generic from ggplot2) produce
graphics of the benchmarked serie and the bending serie.
The functions in_disaggr, in_revisions, in_scatter
produce comparisons on which plot and autoplot can also be used.
The generic accessor functions as.ts
, prais
, coefficients
, residuals
,
fitted.values
, model.list
, se
, rho
extract various useful features of
the returned value.
An object of class "twoStepsBenchmark
" is a list containing the following
components :
benchmarked.serie |
a time series, that is the result of the
benchmark. It is equal to |
fitted.values |
a time series, that is the high-frequency series as it
is after having applied the regression coefficients. Compared to the fitted
values of the regression, which can be retrieved inside the regression
component, it has a high-frequency time series and can eventually be
integrated if |
regression |
an object of class praislm, it is the regression on which relies the benchmark. It can be extracted with the function prais |
smoothed.part |
the smoothed part of the two-steps benchmark. It is
the smoothed difference between the |
model.list |
a list containing all the arguments submitted to the function. |
call |
the matched call (either of twoStepsBenchmark or annualBenchmark) |
Examples
## How to use annualBenchmark or twoStepsBenchark
benchmark <- twoStepsBenchmark(hfserie = turnover,
lfserie = construction,
include.differenciation = TRUE)
as.ts(benchmark)
coef(benchmark)
summary(benchmark)
library(ggplot2)
autoplot(in_sample(benchmark))
## How to manually set the coefficient
benchmark2 <- twoStepsBenchmark(hfserie = turnover,
lfserie = construction,
include.differenciation = TRUE,
set.coeff = 0.1)
coef(benchmark2)