Multivariate Temporal Disaggregation of a System of Time Series by Regression Models.
Source:R/tempdisagg.R
multivariatechowlin.RdPerforms simultaneous temporal disaggregation of a system of low-frequency
time series into higher-frequency series using the multivariate extension of
the Chow-Lin model. When rho = 1 (the default), the method coincides with
the multivariate extension of the Fernandez model, also known as the
multivariate Random Walk model. Additive conversion is assumed, although
average conversion can be accommodated too; see the package vignette for
details.
Usage
multivariatechowlin(
series,
constant = FALSE,
trend = FALSE,
indicators = NULL,
ccseries = NULL,
ccdefinition = NULL,
freq = 4L,
rho = 1,
var = c("fromUnivariate", "allEquals", "userDefined"),
var.includeCov = FALSE,
var.shrinkCov = FALSE,
var.matrix = NULL,
rescale.variance = FALSE
)Arguments
- series
A named list of
tsobjects containing the low frequency time series to be disaggregated.- constant
Either a Boolean or a vector of Booleans. If a vector is provided, each element specifies whether a constant term is included in the model for each series, following the order in which they appear in the
seriesobject. The length of the vector must match the number of series. If a single Boolean is provided (default isFALSE), it is applied to all series. Note that this argument is only used for series withrho < 1(Chow-Lin). For series withrho = 1(Fernandez), a constant term is automatically and implicitly included. See the package vignette or the Details section of the univariatetemporal_disaggregation()function for further information on this.- trend
Either a Boolean or a vector of Booleans. If a vector is provided, each element specifies whether a linear trend is included in the model for each series, following the order in which they appear in the
seriesobject. The length of the vector must match the number of series. If a single Boolean is provided (default isFALSE), it is applied to all series.- indicators
A named list of
tsobjects or a named list of a list oftsobjects. Each element specifies one or more high-frequency indicator(s) associated with one series. If an element isNULL, no indicator is used for the corresponding series. The default value isNULL, meaning that no indicators are used for any series.- ccseries
A named list of
tsobjects containing the contemporaneous constraints. IfNULL(the default), no contemporaneous constraints are considered.- ccdefinition
A character vector defining each contemporaneous constraints. The elements of the vector must be written in the form \(z=w_1 y_1+\ldots+w_n y_n\) or \(c=w_1 y_1+\ldots+w_n y_n\) where:
\(z\) is the name of a contemporaneous constraint,
\((w_1,\ldots,w_n)\) are optional numeric weights,
\((y_1,\ldots,y_n)\) are the names of the time series and
\(c\) is a constant. The default is
NULL, meaning that no contemporaneous constraints are considered.
- freq
An integer giving the annual frequency of the disaggregated series. This argument is ignored when at least one indicator series is provided for any series.
- rho
Either a numeric value or a vector of numeric values. If a vector is provided, each element specifies the value of the
rhoparameter associated to each series, following the order in which they appear in theseriesobject. The length of the vector must match the number of series. If a single numeric value is provided (default is1, corresponding to the Fernandez model), it is applied to all series.- var
A character string specifying the method used to estimate the variance-covariance matrix of the innovations. The default is
"fromUnivariate", meaning that it is estimated empirically from the residuals of the univariate models. Other options include"allEquals", which assumes a diagonal matrix with identical variances, and"userDefined", where the matrix is supplied by the user via thevar.matrixargument. For additional details, see the package vignette.- var.includeCov
Boolean. Indicates whether off-diagonal elements of the innovation variance-covariance matrix should also be estimated from the residuals of the univariate models. The default is
FALSE, meaning that only a diagonal matrix is estimated. This argument is used only whenvar = "fromUnivariate".- var.shrinkCov
Boolean. Indicates whether a shrinkage estimator should be used for covariance estimation. See the package vignette for more details. This argument is used only when
var = "fromUnivariate"andvar.includeCov = TRUE.- var.matrix
The variance-covariance matrix of the innovations. This argument is used only when
var = "userDefined"and must be provided in that case.- rescale.variance
Boolean. Indicates whether the innovation variance-covariance matrix is assumed to be known exactly (the default, which is a natural choice when
var = "fromUnivariate") or only up to a scaling factor. When set toTRUE, the variances of the estimates are rescaled based on the model residuals. This option has no impact on the disaggregated series, but affects the standard errors of both the disaggregated series and the estimated coefficients. See the package vignette for more details.
Value
An object of class "JD3_MULTITEMPDISAGG_RSLTS" is returned. The
following are returned as a list:
regression[[1]]regression coefficients for each series;estimation[[2]]disaggregated time series and standard errors, regression effects, smoothing parts, estimated parameters, and variance-covariance matrix of the innovations;
Vignette
For more information on the method, its arguments, and the other methods available in the package, see the package vignette:
In R:
browseVignettes(package = "rjd3bench")Online: https://rjdverse.github.io/rjd3bench/articles/rjd3bench.html
See also
multivariatecholette() for time series reconciliation.
Examples
# Low-frequency data
Y1 <- ts(
c(30.0, 30.6, 31.2, 31.6),
frequency = 1,
start = c(2010, 1)
)
Y2 <- ts(
c(80.0, 81.2, 82.5, 82.6),
frequency = 1,
start = c(2010, 1)
)
Y3 <- ts(
c(8.0, 8.1, 8.2, 8.2),
frequency = 1,
start = c(2010, 1)
)
lf_series <- list(
y1 = Y1,
y2 = Y2,
y3 = Y3
)
# Contemporaneous constraint
z <- ts(
c(
27.1, 29.8, 29.9, 31.2,
29.4, 27.9, 30.9, 31.7,
29.2, 30.2, 30.6, 31.9,
29.3, 30.4, 30.7, 32.0
),
frequency = 4,
start = c(2010, 1)
)
# High-frequency indicators
x11 <- ts(
c(
7.0, 7.2, 8.1, 7.5,
8.5, 7.8, 8.1, 8.4,
8.6, 7.8, 8.0, 8.3,
8.7, 7.9, 8.0, 8.6
),
frequency = 4,
start = c(2010, 1)
)
x12 <- ts(
c(
18.0, 19.5, 19.0, 19.7,
18.5, 19.0, 20.3, 20.0,
18.6, 19.5, 20.4, 20.1,
18.7, 19.1, 20.4, 20.8
),
frequency = 4,
start = c(2010, 1)
)
x3 <- ts(
c(
1.5, 1.8, 2.0, 2.5,
2.0, 1.5, 1.7, 2.1,
2.1, 1.6, 1.6, 2.2,
2.3, 1.7, 1.9, 2.3
),
frequency = 4,
start = c(2010, 1)
)
indic_series <- list(
y1 = list(x11, x12),
y2 = NULL,
y3 = x3
)
# Check consistency between temporal and contemporaneous constraints
rowSums(cbind(Y1,Y2,Y3)) - stats::aggregate.ts(z) # should all be 0
#> Time Series:
#> Start = 2010
#> End = 2013
#> Frequency = 1
#> [1] 0.000000e+00 1.421085e-14 0.000000e+00 -1.421085e-14
# Estimate models and get results
## Mix Chow-Lin and Fernandez definitions
### with var-cov matrix estimated from the univariate models, assuming zero covariances
mtd1 <- multivariatechowlin(
series = lf_series,
constant = c(FALSE, FALSE, TRUE),
trend = c(FALSE, FALSE, FALSE),
indicators = indic_series,
ccseries = list(z = z),
ccdefinition = "z=y1+y2+y3",
freq = 4L,
rho = c(0.85, 1.0, 0.9),
var = "fromUnivariate",
var.includeCov = FALSE,
var.shrinkCov = FALSE
)
mtd1$estimation$var$vcov # variance-covariance matrix of the innovations
#> [,1] [,2] [,3]
#> [1,] 0.001433366 0.00000000 0.0000000000
#> [2,] 0.000000000 0.01248872 0.0000000000
#> [3,] 0.000000000 0.00000000 0.0008793077
do.call(cbind, mtd1$estimation$disagg) # disaggregated series
#> y1 y2 y3
#> 2010 Q1 6.939861 19.07979 1.080352
#> 2010 Q2 7.943542 20.14422 1.712236
#> 2010 Q3 7.103801 20.64915 2.147051
#> 2010 Q4 8.012796 20.12684 3.060361
#> 2011 Q1 6.722478 20.39456 2.282963
#> 2011 Q2 7.460648 19.08720 1.352157
#> 2011 Q3 8.389319 20.65066 1.860018
#> 2011 Q4 8.027555 21.06758 2.604862
#> 2012 Q1 6.733189 19.97505 2.491760
#> 2012 Q2 7.940522 20.65187 1.607612
#> 2012 Q3 8.411698 20.64922 1.539082
#> 2012 Q4 8.114591 21.22386 2.561545
#> 2013 Q1 6.795370 19.97402 2.530611
#> 2013 Q2 7.800783 21.12535 1.473870
#> 2013 Q3 8.533515 20.43936 1.727128
#> 2013 Q4 8.470332 21.06128 2.468392
do.call(cbind, mtd1$estimation$edisagg) # standard errors of the disaggregated series
#> y1 y2 y3
#> 2010 Q1 0.03140014 0.05000126 0.04327591
#> 2010 Q2 0.02476978 0.02968135 0.02119285
#> 2010 Q3 0.03161386 0.03415475 0.01871516
#> 2010 Q4 0.03136734 0.05527993 0.04896022
#> 2011 Q1 0.03913112 0.04196818 0.02434811
#> 2011 Q2 0.02340147 0.03359607 0.02945418
#> 2011 Q3 0.02800451 0.03102548 0.01904528
#> 2011 Q4 0.02767551 0.03865019 0.03038005
#> 2012 Q1 0.03830267 0.04285251 0.02996976
#> 2012 Q2 0.02426885 0.03137846 0.02520939
#> 2012 Q3 0.02668464 0.03353943 0.02737756
#> 2012 Q4 0.02767089 0.03767300 0.02894481
#> 2013 Q1 0.04082766 0.04553842 0.03185251
#> 2013 Q2 0.02391011 0.03567312 0.03129337
#> 2013 Q3 0.02925037 0.03247505 0.02145259
#> 2013 Q4 0.03205933 0.04177237 0.02975162
### using a shrinkage estimator for covariance
mtd2 <- multivariatechowlin(
series = lf_series,
constant = c(FALSE, FALSE, TRUE),
trend = c(FALSE, FALSE, FALSE),
indicators = indic_series,
ccseries = list(z = z),
ccdefinition = "z=y1+y2+y3",
freq = 4L,
rho = c(0.85, 1.0, 0.9),
var = "fromUnivariate",
var.includeCov = TRUE,
var.shrinkCov = TRUE
)
mtd2$estimation$var$vcov
#> [,1] [,2] [,3]
#> [1,] 1.295161e-03 -0.0011701081 -8.709044e-05
#> [2,] -1.170108e-03 0.0124887216 3.869829e-04
#> [3,] -8.709044e-05 0.0003869829 5.469873e-05
do.call(cbind, mtd2$estimation$disagg)
#> y1 y2 y3
#> 2010 Q1 7.032124 18.38361 1.684270
#> 2010 Q2 7.867589 20.02459 1.907825
#> 2010 Q3 7.119255 20.72811 2.052637
#> 2010 Q4 7.981033 20.86370 2.355269
#> 2011 Q1 6.819908 20.48156 2.098528
#> 2011 Q2 7.561817 18.55115 1.787037
#> 2011 Q3 8.271285 20.64734 1.981372
#> 2011 Q4 7.946990 21.51995 2.233063
#> 2012 Q1 6.910851 20.10656 2.182591
#> 2012 Q2 7.892070 20.40384 1.904089
#> 2012 Q3 8.348688 20.36685 1.884465
#> 2012 Q4 8.048390 21.62275 2.228855
#> 2013 Q1 6.989663 20.10942 2.200913
#> 2013 Q2 7.713462 20.82079 1.865750
#> 2013 Q3 8.479224 20.27804 1.942738
#> 2013 Q4 8.417651 21.39175 2.190598
do.call(cbind, mtd2$estimation$edisagg)
#> y1 y2 y3
#> 2010 Q1 0.03122149 0.03489408 0.019437511
#> 2010 Q2 0.02459679 0.02399429 0.007654569
#> 2010 Q3 0.03134501 0.02994026 0.004814822
#> 2010 Q4 0.03130689 0.03796795 0.023463260
#> 2011 Q1 0.03864249 0.03703555 0.007587635
#> 2011 Q2 0.02316806 0.02491433 0.013169227
#> 2011 Q3 0.02774779 0.02658016 0.005866159
#> 2011 Q4 0.02773848 0.02863357 0.012295687
#> 2012 Q1 0.03750810 0.03678671 0.011896099
#> 2012 Q2 0.02409236 0.02446696 0.010436899
#> 2012 Q3 0.02617920 0.02674504 0.011862534
#> 2012 Q4 0.02772939 0.02812739 0.011246403
#> 2013 Q1 0.04000515 0.03923857 0.012754946
#> 2013 Q2 0.02372702 0.02587995 0.014001100
#> 2013 Q3 0.02882478 0.02793242 0.007815651
#> 2013 Q4 0.03207397 0.03165254 0.010269251
## Multivariate random walk model (multivariate Fernandez)
### with var-cov matrix provided by the user
mtd3 <- multivariatechowlin(
series = lf_series,
constant = FALSE,
trend = FALSE,
indicators = indic_series,
ccseries = list(z = z),
ccdefinition = "z=y1+y2+y3",
freq = 4L,
rho = 1.0,
var = "userDefined",
var.matrix = matrix(
c(5, 2, 1,
2, 10, 2,
1, 2, 3),
nrow = 3,
byrow = TRUE
),
rescale.variance = TRUE
)
mtd3$estimation$var$vcov
#> [,1] [,2] [,3]
#> [1,] 5 2 1
#> [2,] 2 10 2
#> [3,] 1 2 3
do.call(cbind, mtd3$estimation$disagg)
#> y1 y2 y3
#> 2010 Q1 6.108983 19.72409 1.266923
#> 2010 Q2 8.107219 19.93250 1.760283
#> 2010 Q3 7.529320 20.21029 2.160388
#> 2010 Q4 8.254477 20.13312 2.812406
#> 2011 Q1 6.686679 20.40719 2.306128
#> 2011 Q2 6.797711 19.73210 1.370185
#> 2011 Q3 8.685776 20.33348 1.880741
#> 2011 Q4 8.429835 20.72722 2.542946
#> 2012 Q1 6.400284 20.43743 2.362291
#> 2012 Q2 7.685207 20.74189 1.772905
#> 2012 Q3 8.618610 20.41449 1.566905
#> 2012 Q4 8.495899 20.90620 2.497900
#> 2013 Q1 6.451413 20.47755 2.371039
#> 2013 Q2 7.378121 21.19157 1.830307
#> 2013 Q3 8.590304 20.39480 1.714896
#> 2013 Q4 9.180162 20.53608 2.283757
do.call(cbind, mtd3$estimation$edisagg)
#> y1 y2 y3
#> 2010 Q1 0.9220615 0.7989343 0.8622564
#> 2010 Q2 0.4768654 0.4866868 0.4006106
#> 2010 Q3 0.6551743 0.5625929 0.3984178
#> 2010 Q4 0.6691278 0.7896144 0.8948905
#> 2011 Q1 0.6998249 0.6385928 0.4871380
#> 2011 Q2 0.6558340 0.5338923 0.5923964
#> 2011 Q3 0.5467235 0.5141900 0.3727830
#> 2011 Q4 0.6137986 0.6053674 0.5866327
#> 2012 Q1 0.7170487 0.6785675 0.5725294
#> 2012 Q2 0.5621174 0.4940398 0.5017914
#> 2012 Q3 0.5367615 0.5579618 0.5031171
#> 2012 Q4 0.6137582 0.6007979 0.5642130
#> 2013 Q1 0.7648739 0.7176635 0.6192982
#> 2013 Q2 0.7372759 0.5875706 0.6343860
#> 2013 Q3 0.5358664 0.5044930 0.4166496
#> 2013 Q4 0.8889961 0.7641042 0.6227456