Type: | Package |
Title: | Factor-Adjusted Network Estimation and Forecasting for High-Dimensional Time Series |
Version: | 0.1.6 |
Maintainer: | Haeran Cho <haeran.cho@bristol.ac.uk> |
Description: | Implements methods for network estimation and forecasting of high-dimensional time series exhibiting strong serial and cross-sectional correlations under a factor-adjusted vector autoregressive model. See Barigozzi, Cho and Owens (2024+) <doi:10.1080/07350015.2023.2257270> for further descriptions of FNETS methodology and Owens, Cho and Barigozzi (2024+) <doi:10.48550/arXiv.2301.11675> accompanying the R package. |
Depends: | R (≥ 4.1.0) |
Imports: | lpSolve, parallel, doParallel, foreach, MASS, fields, igraph, RColorBrewer |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.1 |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2024-01-23 08:17:08 UTC; h |
Author: | Matteo Barigozzi [aut], Haeran Cho [cre, aut], Dom Owens [aut] |
Repository: | CRAN |
Date/Publication: | 2024-01-23 09:30:03 UTC |
Bartlett weights
Description
Bartlett weights
Usage
Bartlett.weights(x)
Factor number estimator of Alessi, Barigozzi and Capasso (2010)
Description
Estimates the number of factors by minimising an information criterion over sub-samples of the data.
Currently the three information criteria proposed in Alessi, Barigozzi and Capasso (2010) (ic.op = 1, 2, 3
)
and their variations with logarithm taken on the cost (ic.op = 4, 5, 6
) are implemented,
with ic.op = 5
recommended as a default choice based on numerical experiments.
Usage
abc.factor.number(x, covx = NULL, q.max = NULL, center = TRUE)
Arguments
x |
input time series matrix, with each row representing a variable |
covx |
covariance of |
q.max |
maximum number of factors; if |
center |
whether to de-mean the input |
Details
See Alessi, Barigozzi and Capasso (2010) for further details.
Value
a list containing
q.hat |
the mimimiser of the chosen information criteria |
References
Alessi, L., Barigozzi, M., & Capasso, M. (2010) Improved penalization for determining the number of factors in approximate factor models. Statistics & Probability Letters, 80(23-24):1806–1813.
Blockwise VAR estimation under GDFM
Description
Blockwise VAR estimation under GDFM
Usage
common.irf.estimation(
xx,
Gamma_c,
q,
factor.var.order = NULL,
max.var.order = NULL,
trunc.lags,
n.perm
)
Forecasting the factor-driven common component
Description
Produces forecasts of the common component for a given forecasting horizon by estimating the best linear predictors
Usage
common.predict(object, x, n.ahead = 1, fc.restricted = TRUE, r = c("ic", "er"))
Arguments
object |
|
x |
input time series matrix, with each row representing a variable |
n.ahead |
forecasting horizon |
fc.restricted |
whether to forecast using a restricted or unrestricted, blockwise VAR representation of the common component |
r |
number of restricted factors, or a string specifying the factor number selection method when
|
Value
a list containing
is |
in-sample estimator of the common component (with each column representing a variable) |
fc |
forecasts of the common component for a given forecasting horizon |
r |
restricted factor number |
n.ahead |
forecast horizon |
References
Ahn, S. C. & Horenstein, A. R. (2013) Eigenvalue ratio test for the number of factors. Econometrica, 81(3), 1203–1227.
Alessi, L., Barigozzi, M., and Capasso, M. (2010) Improved penalization for determining the number of factors in approximate factor models. Statistics & Probability Letters, 80(23-24):1806–1813.
Barigozzi, M., Cho, H. & Owens, D. (2024+) FNETS: Factor-adjusted network estimation and forecasting for high-dimensional time series. Journal of Business & Economic Statistics (to appear).
Forni, M., Hallin, M., Lippi, M. & Reichlin, L. (2005) The generalized dynamic factor model: one-sided estimation and forecasting. Journal of the American Statistical Association, 100(471), 830–840.
Forni, M., Hallin, M., Lippi, M. & Zaffaroni, P. (2017) Dynamic factor models with infinite-dimensional factor space: Asymptotic analysis. Journal of Econometrics, 199(1), 74–92.
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
Examples
## Not run:
out <- fnets(data.unrestricted, q = NULL, var.order = 1, var.method = "lasso",
do.lrpc = FALSE, var.args = list(n.cores = 2))
cpre <- common.predict(out)
ipre <- idio.predict(out, cpre)
## End(Not run)
Simulated data from the restricted factor-adjusted vector autoregression model
Description
set.seed(123)
n <- 500
p <- 50
common <- sim.restricted(n, p)
idio <- sim.var(n, p)
x <- common$data + idio$data
Usage
data.restricted
Format
## 'data.restricted' A ts object with 500 rows (observations) and 50 columns (series)
Simulated data from the unrestricted factor-adjusted vector autoregression model
Description
set.seed(123)
n <- 500
p <- 50
common <- sim.unrestricted(n, p)
idio <- sim.var(n, p)
x <- common$data + idio$data
Usage
data.unrestricted
Format
## 'data.unrestricted' A ts object with 500 rows (observations) and 50 columns (series)
Dynamic PCA
Description
Performs principal components analysis in frequency domain for identifying common and idiosyncratic components.
Usage
dyn.pca(
xx,
q = NULL,
q.method = c("ic", "er"),
ic.op = 5,
kern.bw = NULL,
mm = NULL
)
Arguments
xx |
centred input time series matrix, with each row representing a variable |
q |
number of factors. If |
q.method |
A string specifying the factor number selection method; possible values are:
|
ic.op |
choice of the information criterion penalty. Currently the three options from Hallin and Liška (2007) ( |
kern.bw |
a positive integer specifying the kernel bandwidth for dynamic PCA; by default, it is set to |
mm |
bandwidth |
Value
a list containing
q |
number of factors |
q.method.out |
if |
spec |
a list containing the estimates of the spectral density matrices for |
acv |
a list containing estimates of the autocovariance matrices for |
kern.bw |
input parameter |
extended Bayesian Information Criterion
Description
extended Bayesian Information Criterion
Usage
ebic(object, n, penalty = 0)
full likelihood
Description
full likelihood
Usage
f.func.full(GG, gg, A)
Factor number selection methods
Description
Methods to estimate the number of factor.
When method = 'er'
, the factor number is estimated by maximising the ration of successive eigenvalues.
When method = 'ic'
, the information criterion-methods discussed in Hallin and Liška (2007) (when fm.restricted = FALSE
)
and Alessi, Barigozzi and Capasso (2010) (when fm.restricted = TRUE
) are implemented.
The information criterion called by ic.op = 5
(as an argument to fnets
or fnets.factor.model
) is recommended by default.
Usage
factor.number(
x,
fm.restricted = FALSE,
method = c("ic", "er"),
q.max = NULL,
center = TRUE
)
Arguments
x |
input time series each column representing a time series variable; it is coerced into a ts object |
fm.restricted |
whether to estimate the number of restricted or unrestricted factors |
method |
A string specifying the factor number selection method; possible values are:
|
q.max |
maximum number of factors; if |
center |
whether to de-mean the input |
Details
For further details, see references.
Value
S3 object of class factor.number
.
If method = "ic"
, a vector containing minimisers of the six information criteria, otherwise, the maximiser of the eigenvalue ratio
References
Ahn, S. C. & Horenstein, A. R. (2013) Eigenvalue ratio test for the number of factors. Econometrica, 81(3), 1203–1227.
Alessi, L., Barigozzi, M., and Capasso, M. (2010) Improved penalization for determining the number of factors in approximate factor models. Statistics & Probability Letters, 80(23-24):1806–1813.
Avarucci, M., Cavicchioli, M., Forni, M., & Zaffaroni, P. (2022) The main business cycle shock(s): Frequency-band estimation of the number of dynamic factors.
Hallin, M. & Liška, R. (2007) Determining the number of factors in the general dynamic factor model. Journal of the American Statistical Association, 102(478), 603–617.
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
See Also
plot.factor.number, print.factor.number
Examples
library(fnets)
## Alessi, Barigozzi, and Capasso method for restricted models
abc <- factor.number(data.restricted, fm.restricted = TRUE)
print(abc)
plot(abc)
## Eigenvalue ratio method
er <- factor.number(data.restricted, method = "er", fm.restricted = TRUE)
print(er)
plot(er)
## Hallin and Liška method for unrestricted models
hl <- factor.number(data.unrestricted, fm.restricted = FALSE)
print(hl)
plot(hl)
Factor-adjusted network estimation
Description
Under a factor-adjusted vector autoregressive (VAR) model, the function estimates the spectral density and autocovariance matrices of the factor-driven common component and the idiosyncratic VAR process, the impulse response functions and common shocks for the common component, and VAR parameters, innovation covariance matrix and long-run partial correlations for the idiosyncratic component.
Usage
fnets(
x,
center = TRUE,
fm.restricted = FALSE,
q = c("ic", "er"),
ic.op = NULL,
kern.bw = NULL,
common.args = list(factor.var.order = NULL, max.var.order = NULL, trunc.lags = 20,
n.perm = 10),
var.order = 1,
var.method = c("lasso", "ds"),
var.args = list(n.iter = NULL, n.cores = 1),
do.threshold = FALSE,
do.lrpc = TRUE,
lrpc.adaptive = FALSE,
tuning.args = list(tuning = c("cv", "bic"), n.folds = 1, penalty = NULL, path.length =
10)
)
Arguments
x |
input time series each column representing a time series variable; it is coerced into a ts object |
center |
whether to de-mean the input |
fm.restricted |
whether to estimate a restricted factor model using static PCA |
q |
Either the number of factors or a string specifying the factor number selection method; possible values are:
see factor.number. |
ic.op |
choice of the information criterion penalty, see factor.number for further details |
kern.bw |
a positive integer specifying the kernel bandwidth for dynamic PCA; by default, it is set to |
common.args |
a list specifying the tuning parameters required for estimating the impulse response functions and common shocks. It contains:
|
var.order |
order of the idiosyncratic VAR process; if a vector of integers is supplied, the order is chosen via |
var.method |
a string specifying the method to be adopted for idiosyncratic VAR process estimation; possible values are:
|
var.args |
a list specifying the tuning parameters required for estimating the idiosyncratic VAR process. It contains:
|
do.threshold |
whether to perform adaptive thresholding of all parameter estimators with threshold |
do.lrpc |
whether to estimate the long-run partial correlation |
lrpc.adaptive |
whether to use the adaptive estimation procedure |
tuning.args |
a list specifying arguments for selecting the tuning parameters involved in VAR parameter and (long-run) partial correlation matrix estimation. It contains:
by default
|
Details
See Barigozzi, Cho and Owens (2024+) for further details. List arguments do not need to be specified with all list components; any missing entries will be filled in with the default argument.
Value
an S3 object of class fnets
, which contains the following fields:
q |
number of factors |
spec |
if |
acv |
a list containing estimates of the autocovariance matrices for |
loadings |
if |
factors |
if |
idio.var |
a list containing the following fields:
|
lrpc |
see the output of par.lrpc |
mean.x |
if |
var.method |
input parameter |
do.lrpc |
input parameter |
kern.bw |
input parameter |
References
Ahn, S. C. & Horenstein, A. R. (2013) Eigenvalue ratio test for the number of factors. Econometrica, 81(3), 1203–1227.
Alessi, L., Barigozzi, M., & Capasso, M. (2010) Improved penalization for determining the number of factors in approximate factor models. Statistics & Probability Letters, 80(23-24):1806–1813.
Avarucci, M., Cavicchioli, M., Forni, M., & Zaffaroni, P. (2022) The main business cycle shock(s): Frequency-band estimation of the number of dynamic factors.
Barigozzi, M., Cho, H. & Owens, D. (2024+) FNETS: Factor-adjusted network estimation and forecasting for high-dimensional time series. Journal of Business & Economic Statistics (to appear).
Hallin, M. & Liška, R. (2007) Determining the number of factors in the general dynamic factor model. Journal of the American Statistical Association, 102(478), 603–617.
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
See Also
predict.fnets, plot.fnets, print.fnets
Examples
out <- fnets(data.unrestricted,
do.threshold = TRUE,
var.args = list(n.cores = 2)
)
pre <- predict(out, common.method = "unrestricted")
plot(out, type = "granger", display = "network")
plot(out, type = "lrpc", display = "heatmap")
Factor model estimation
Description
Performs factor modelling under either restricted (static) or unrestricted (dynamic) factor models
Usage
fnets.factor.model(
x,
center = TRUE,
fm.restricted = FALSE,
q = c("ic", "er"),
ic.op = NULL,
kern.bw = NULL,
common.args = list(factor.var.order = NULL, max.var.order = NULL, trunc.lags = 20,
n.perm = 10)
)
Arguments
x |
input time series each column representing a time series variable; it is coerced into a ts object |
center |
whether to de-mean the input |
fm.restricted |
whether to estimate a restricted factor model using static PCA |
q |
Either a string specifying the factor number selection method when
or the number of unrestricted factors, see factor.number |
ic.op |
choice of the information criterion penalty, see hl.factor.number or abc.factor.number for further details |
kern.bw |
a positive integer specifying the kernel bandwidth for dynamic PCA;
by default, it is set to |
common.args |
a list specifying the tuning parameters required for estimating the impulse response functions and common shocks. It contains:
|
Details
See Barigozzi, Cho and Owens (2024+) for further details.
Value
an S3 object of class fm
, which contains the following fields:
q |
number of factors |
spec |
if |
acv |
a list containing estimates of the autocovariance matrices for |
loadings |
if |
factors |
if |
mean.x |
if |
References
Ahn, S. C. & Horenstein, A. R. (2013) Eigenvalue ratio test for the number of factors. Econometrica, 81(3), 1203–1227.
Alessi, L., Barigozzi, M., & Capasso, M. (2010) Improved penalization for determining the number of factors in approximate factor models. Statistics & Probability Letters, 80(23-24):1806–1813.
Avarucci, M., Cavicchioli, M., Forni, M., & Zaffaroni, P. (2022) The main business cycle shock(s): Frequency-band estimation of the number of dynamic factors.
Barigozzi, M., Cho, H. & Owens, D. (2024+) FNETS: Factor-adjusted network estimation and forecasting for high-dimensional time series. Journal of Business & Economic Statistics (to appear).
Hallin, M. & Liška, R. (2007) Determining the number of factors in the general dynamic factor model. Journal of the American Statistical Association, 102(478), 603–617.
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
See Also
Examples
out <- fnets.factor.model(data.restricted, fm.restricted = TRUE)
l1
-regularised Yule-Walker estimation for VAR processes
Description
Estimates the VAR parameter matrices via l1
-regularised Yule-Walker estimation
and innovation covariance matrix via constrained l1
-minimisation.
Usage
fnets.var(
x,
center = TRUE,
method = c("lasso", "ds"),
lambda = NULL,
var.order = 1,
tuning.args = list(tuning = c("cv", "bic"), n.folds = 1, penalty = NULL, path.length =
10),
do.threshold = FALSE,
n.iter = NULL,
tol = 0,
n.cores = 1
)
Arguments
x |
input time series each column representing a time series variable; it is coerced into a ts object |
center |
whether to de-mean the input |
method |
a string specifying the method to be adopted for VAR process estimation; possible values are:
|
lambda |
|
var.order |
order of the VAR process; if a vector of integers is supplied, the order is chosen via |
tuning.args |
a list specifying arguments for
by default
|
do.threshold |
whether to perform adaptive thresholding of VAR parameter estimator with threshold |
n.iter |
maximum number of descent steps, by default depends on |
tol |
numerical tolerance for increases in the loss function; applicable when |
n.cores |
number of cores to use for parallel computing, see makePSOCKcluster; applicable when |
Details
Further information can be found in Barigozzi, Cho and Owens (2024+).
Value
a list which contains the following fields:
beta |
estimate of VAR parameter matrix; each column contains parameter estimates for the regression model for a given variable |
Gamma |
estimate of the innovation covariance matrix |
lambda |
|
var.order |
VAR order |
mean.x |
if |
References
Barigozzi, M., Cho, H. & Owens, D. (2024+) FNETS: Factor-adjusted network estimation and forecasting for high-dimensional time series. Journal of Business & Economic Statistics (to appear).
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
Examples
library(fnets)
set.seed(123)
n <- 500
p <- 50
idio <- sim.var(n, p)
x <- idio$data
fv <- fnets.var(x,
n.cores = 2
)
internal function for fnets.var
Description
internal function for fnets.var
Usage
fnets.var.internal(
xx,
acv,
method = c("lasso", "ds"),
lambda = NULL,
var.order = 1,
tuning.args = list(tuning = c("cv", "bic"), n.folds = 1, penalty = NULL, path.length =
10),
do.threshold = FALSE,
n.iter = NULL,
tol = 0,
n.cores = 1
)
Factor number estimator of Hallin and Liška (2007)
Description
Estimates the number of factors by minimising an information criterion over sub-samples of the data.
Currently the three information criteria proposed in Hallin and Liška (2007) (ic.op = 1, 2
or 3
)
and their variations with logarithm taken on the cost (ic.op = 4, 5
or 6
) are implemented,
with ic.op = 5
recommended as a default choice based on numerical experiments.
Usage
hl.factor.number(x, q.max = NULL, mm = NULL, center = TRUE)
Arguments
x |
input time series matrix, with each row representing a variable |
q.max |
maximum number of factors; if |
mm |
a positive integer specifying the kernel bandwidth for dynamic PCA; by default, it is set to |
center |
whether to de-mean the input |
Details
See Hallin and Liška (2007) for further details.
Value
a list containing
q.hat |
a vector containing minimisers of the six information criteria |
References
Hallin, M. & Liška, R. (2007) Determining the number of factors in the general dynamic factor model. Journal of the American Statistical Association, 102(478), 603–617.
Forecasting idiosyncratic VAR process
Description
Produces forecasts of the idiosyncratic VAR process for a given forecasting horizon by estimating the best linear predictors
Usage
idio.predict(object, x, cpre, n.ahead = 1)
Arguments
object |
|
x |
input time series, with each row representing a variable |
cpre |
output of common.predict |
n.ahead |
forecast horizon |
Value
a list containing
is |
in-sample estimator of the idiosyncratic component (with each column representing a variable) |
fc |
forecasts of the idiosyncratic component for a given forecasting horizon |
n.ahead |
forecast horizon |
Examples
## Not run:
out <- fnets(data.unrestricted,
do.lrpc = FALSE, var.args = list(n.cores = 2))
cpre <- common.predict(out)
ipre <- idio.predict(out, cpre)
## End(Not run)
logarithmic factorial of 'n'
Description
logarithmic factorial of 'n'
Usage
logfactorial(n)
Convert networks into igraph objects
Description
Convert networks into igraph objects
Usage
network(object, ...)
Arguments
object |
object |
... |
additional arguments |
See Also
Convert networks estimated by fnets into igraph objects
Description
Converts S3 objects of class fnets
into a network.
Produces an igraph object for the three networks underlying factor-adjusted VAR processes:
(i) directed network representing Granger causal linkages, as given by estimated VAR transition matrices summed across the lags,
(ii) undirected network representing contemporaneous linkages after accounting for lead-lag dependence, as given by partial correlations of VAR innovations,
(iii) undirected network summarising (i) and (ii) as given by long-run partial correlations of VAR processes.
When plotting the network, note that the edge weights may be negative since they correspond to the entries of the estimators of VAR parameters and (long-run) partial correlations.
Usage
## S3 method for class 'fnets'
network(
object,
type = c("granger", "pc", "lrpc"),
names = NA,
groups = NA,
group.colours = NA,
...
)
Arguments
object |
|
type |
a string specifying which of the above three networks (i)–(iii) to visualise; possible values are
|
names |
a character vector containing the names of the vertices |
groups |
an integer vector denoting any group structure of the vertices |
group.colours |
a vector denoting colours corresponding to |
... |
additional arguments to |
Value
a list containing
network |
|
names |
input argument |
groups |
input argument |
grp.col |
vector of colours corresponding to each node |
... |
additional arguments to |
See Also
Examples
out <- fnets(data.unrestricted,
do.threshold = TRUE,
var.args = list(n.cores = 2)
)
net <- network(out, type = "granger")$network
plot(net, layout = igraph::layout_in_circle(net))
network(out, type = "pc")
network(out, type = "lrpc")
Parametric estimation of long-run partial correlations of factor-adjusted VAR processes
Description
Returns a parametric estimate of long-run partial correlations of the VAR process
from the VAR parameter estimates and the inverse of innovation covariance matrix obtained via constrained l1
-minimisation.
Usage
par.lrpc(
object,
eta = NULL,
tuning.args = list(n.folds = 1, path.length = 10),
lrpc.adaptive = FALSE,
eta.adaptive = NULL,
do.correct = TRUE,
do.threshold = FALSE,
n.cores = 1
)
Arguments
object |
|
eta |
|
tuning.args |
a list specifying arguments for the cross validation procedure for selecting the tuning parameter involved in long-run partial correlation matrix estimation. It contains:
|
lrpc.adaptive |
whether to use the adaptive estimation procedure |
eta.adaptive |
|
do.correct |
whether to correct for any negative entries in the diagonals of the inverse of long-run covariance matrix |
do.threshold |
whether to perform adaptive thresholding of |
n.cores |
number of cores to use for parallel computing, see makePSOCKcluster |
Details
See Barigozzi, Cho and Owens (2024+) for further details, and Cai, Liu and Zhou (2016) for further details on the adaptive estimation procedure.
Value
a list containing
Delta |
estimated inverse of the innovation covariance matrix |
Omega |
estimated inverse of the long-run covariance matrix |
pc |
estimated innovation partial correlation matrix |
lrpc |
estimated long-run partial correlation matrix |
eta |
|
lrpc.adaptive |
input argument |
References
Barigozzi, M., Cho, H. & Owens, D. (2024+) FNETS: Factor-adjusted network estimation and forecasting for high-dimensional time series. Journal of Business & Economic Statistics (to appear).
Cai, T. T., Liu, W., & Zhou, H. H. (2016) Estimating sparse precision matrix: Optimal rates of convergence and adaptive estimation. The Annals of Statistics, 44(2), 455-488.
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
Examples
out <- fnets(data.unrestricted, do.lrpc = FALSE, var.args = list(n.cores = 2))
plrpc <- par.lrpc(out, n.cores = 2)
out$lrpc <- plrpc
out$do.lrpc <- TRUE
plot(out, type = "pc", display = "network")
plot(out, type = "lrpc", display = "heatmap")
Plot factor number
Description
Plots the eigenvalue ratio or information criteria from a factor.number
object
Usage
## S3 method for class 'factor.number'
plot(x, ...)
Arguments
x |
|
... |
not used |
Value
NULL, printed to console
See Also
Examples
library(fnets)
## Alessi, Barigozzi, and Capasso method for restricted models
abc <- factor.number(data.restricted, fm.restricted = TRUE)
print(abc)
plot(abc)
## Eigenvalue ratio method
er <- factor.number(data.restricted, method = "er", fm.restricted = TRUE)
print(er)
plot(er)
## Hallin and Liška method for unrestricted models
hl <- factor.number(data.unrestricted, fm.restricted = FALSE)
print(hl)
plot(hl)
Plotting the networks estimated by fnets
Description
Plotting method for S3 objects of class fnets
.
When display = "network"
or display = "heatmap"
, it produces a plot visualising three networks underlying factor-adjusted VAR processes:
(i) directed network representing Granger causal linkages, as given by estimated VAR transition matrices summed across the lags,
(ii) undirected network representing contemporaneous linkages after accounting for lead-lag dependence, as given by partial correlations of VAR innovations,
(iii) undirected network summarising (i) and (ii) as given by long-run partial correlations of VAR processes.
Edge widths are determined by edge weights.
When display = "tuning"
, it produces up to two plots (when do.larpc = TRUE
) visualising
the outcome of CV or IC adopted for selecting the l1
-regularisation parameters and the VAR order.
Usage
## S3 method for class 'fnets'
plot(
x,
type = c("granger", "pc", "lrpc"),
display = c("network", "heatmap", "tuning"),
names = NA,
groups = NA,
group.colours = NA,
...
)
Arguments
x |
|
type |
a string specifying which of the above three networks (i)–(iii) to visualise
when
|
display |
a string specifying which plot to produce; possible values are
|
names |
a character vector containing the names of the network vertices |
groups |
an integer vector denoting any group structure of the network vertices |
group.colours |
a vector denoting colours corresponding to |
... |
additional arguments |
Value
A plot produced as per the input arguments
See Also
Examples
out <- fnets(data.unrestricted,
do.threshold = TRUE,
var.args = list(n.cores = 2)
)
plot(out, type = "granger", display = "network",
groups = rep(c(1,2), 50/2), group.colours = c("orange","blue"))
plot(out, type = "lrpc", display = "heatmap")
plot(out, display = "tuning")
Plotting the thresholding procedure
Description
Plotting method for S3 objects of class threshold
.
Produces a plot visualising three diagnostics for the thresholding procedure, with threshold values t_k (x axis) against
(i) Ratio_k, the ratio of the number of non-zero to zero entries in the matrix, as the threshold varies
(ii) Diff_k, the first difference of Ratio_k
(iii) |CUSUM_k|, the absolute scaled cumulative sums of Diff_k
Usage
## S3 method for class 'threshold'
plot(x, plots = c(TRUE, FALSE, TRUE), ...)
Arguments
x |
|
plots |
logical vector, which plots to use (Ratio, Diff, CUSUM respectively) |
... |
additional arguments |
Details
See Owens, Cho and Barigozzi (2024+) for further details.
Value
A network plot produced as per the input arguments
References
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
See Also
Examples
## Not run:
library(fnets)
out <- fnets(data.unrestricted,
var.args = list(n.cores = 2)
)
# Granger-causal network
th1 <- threshold(out$idio.var$beta)
plot(th1)
print(th1)
# Partial correlations
th2 <- threshold(out$lrpc$pc)
# Long-run partial correlations
th3 <- threshold(out$lrpc$lrpc)
## End(Not run)
internal function for plot.fnets
and network
Description
internal function for plot.fnets
and network
Usage
plot_internal(
x,
type = c("granger", "pc", "lrpc"),
display = c("network", "heatmap"),
names = NA,
groups = NA,
group.colours = NA,
...
)
Forecasting for factor models
Description
Produces forecasts of the data input to object
for a given forecasting horizon by
estimating the best linear predictors of the common component
Usage
## S3 method for class 'fm'
predict(object, n.ahead = 1, fc.restricted = TRUE, r = c("ic", "er"), ...)
Arguments
object |
|
n.ahead |
forecasting horizon |
fc.restricted |
if |
r |
number of static factors, or a string specifying the factor number selection method when
|
... |
not used |
Value
a list containing
is |
in-sample predictions |
forecast |
forecasts for the given forecasting horizon |
r |
factor number |
See Also
Examples
out <- fnets.factor.model(data.restricted, fm.restricted = TRUE)
pre <- predict(out)
Forecasting by fnets
Description
Produces forecasts of the data for a given forecasting horizon by separately estimating the best linear predictors of common and idiosyncratic components
Usage
## S3 method for class 'fnets'
predict(
object,
newdata = NULL,
n.ahead = 1,
fc.restricted = TRUE,
r = c("ic", "er"),
...
)
Arguments
object |
|
newdata |
input time series matrix; by default, uses input to |
n.ahead |
forecasting horizon |
fc.restricted |
whether to forecast using a restricted or unrestricted, blockwise VAR representation of the common component |
r |
number of static factors, or a string specifying the factor number selection method when
|
... |
not used |
Value
a list containing
forecast |
forecasts for the given forecasting horizon |
common.pred |
a list containing forecasting results for the common component |
idio.pred |
a list containing forecasting results for the idiosyncratic component |
mean.x |
|
See Also
Examples
out <- fnets(data.restricted, q = 2, do.lrpc = FALSE, var.args = list(n.cores = 2))
pre.unr <- predict(out, fc.restricted = FALSE)
pre.res <- predict(out, fc.restricted = TRUE)
Print factor number
Description
Prints a summary of a factor.number
object
Usage
## S3 method for class 'factor.number'
print(x, ...)
Arguments
x |
|
... |
not used |
Value
NULL, printed to console
See Also
Examples
library(fnets)
## Alessi, Barigozzi, and Capasso method for restricted models
abc <- factor.number(data.restricted, fm.restricted = TRUE)
print(abc)
plot(abc)
## Eigenvalue ratio method
er <- factor.number(data.restricted, method = "er", fm.restricted = TRUE)
print(er)
plot(er)
## Hallin and Liška method for unrestricted models
hl <- factor.number(data.unrestricted, fm.restricted = FALSE)
print(hl)
plot(hl)
Print factor model
Description
Prints a summary of a fm
object
Usage
## S3 method for class 'fm'
print(x, ...)
Arguments
x |
|
... |
not used |
Value
NULL, printed to console
See Also
Examples
out <- fnets.factor.model(data.restricted, q = "ic")
print(out)
Print fnets
Description
Prints a summary of a fnets
object
Usage
## S3 method for class 'fnets'
print(x, ...)
Arguments
x |
|
... |
not used |
Value
NULL, printed to console
See Also
Examples
out <- fnets(data.restricted, q = 2,
do.lrpc = FALSE, var.args = list(n.cores = 2))
print(out)
x <- sim.var(500, 50)$data
out <- fnets.var(x,
n.cores = 2)
print(out)
Print threshold
Description
Prints a summary of a threshold
object
Usage
## S3 method for class 'threshold'
print(x, ...)
Arguments
x |
|
... |
not used |
Value
NULL, printed to console
See Also
Examples
## Not run:
library(fnets)
out <- fnets(data.unrestricted,
var.args = list(n.cores = 2)
)
# Granger-causal network
th1 <- threshold(out$idio.var$beta)
plot(th1)
print(th1)
# Partial correlations
th2 <- threshold(out$lrpc$pc)
# Long-run partial correlations
th3 <- threshold(out$lrpc$lrpc)
## End(Not run)
Simulate data from a restricted factor model
Description
Simulate the common component following an unrestricted factor model that admits a restricted representation; see the model (C2) in the reference.
Usage
sim.restricted(n, p, q = 2, heavy = FALSE)
Arguments
n |
sample size |
p |
dimension |
q |
number of unrestricted factors; number of restricted factors is given by |
heavy |
if |
Value
a list containing
data |
|
q |
number of factors |
r |
number of restricted factors |
References
Barigozzi, M., Cho, H. & Owens, D. (2024+) FNETS: Factor-adjusted network estimation and forecasting for high-dimensional time series. Journal of Business & Economic Statistics (to appear).
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
Examples
common <- sim.restricted(500, 50)
Simulate data from an unrestricted factor model
Description
Simulate the common component following an unrestricted factor model that does not admit a restricted representation; see the model (C1) in Barigozzi, Cho and Owens (2024+)
Usage
sim.unrestricted(n, p, q = 2, heavy = FALSE)
Arguments
n |
sample size |
p |
dimension |
q |
number of unrestricted factors |
heavy |
if |
Value
a list containing
data |
|
q |
number of factors |
References
Barigozzi, M., Cho, H. & Owens, D. (2024+) FNETS: Factor-adjusted network estimation and forecasting for high-dimensional time series. Journal of Business & Economic Statistics (to appear).
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
Examples
common <- sim.unrestricted(500, 50)
Simulate a VAR(1) process
Description
Simulate a VAR(1) process; see the reference for the generation of the transition matrix.
Usage
sim.var(n, p, Gamma = diag(1, p), heavy = FALSE)
Arguments
n |
sample size |
p |
dimension |
Gamma |
innovation covariance matrix; ignored if |
heavy |
if |
Value
a list containing
data |
|
A |
transition matrix |
Gamma |
innovation covariance matrix |
References
Barigozzi, M., Cho, H. & Owens, D. (2024+) FNETS: Factor-adjusted network estimation and forecasting for high-dimensional time series. Journal of Business & Economic Statistics (to appear).
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
Examples
idio <- sim.var(500, 50)
Static PCA
Description
Static PCA
Usage
static.pca(
xx,
q = NULL,
q.method = c("ic", "er"),
q.max = NULL,
ic.op = 2,
mm = NULL
)
Threshold the entries of the input matrix at a data-driven level
Description
Threshold the entries of the input matrix at a data-driven level. This can be used to perform edge selection for VAR parameter, inverse innovation covariance, and long-run partial correlation networks.
Usage
threshold(mat, path.length = 500)
Arguments
mat |
input parameter matrix |
path.length |
number of candidate thresholds |
Details
See Owens, Cho & Barigozzi (2024+) for more information on the threshold selection process
Value
an S3 object of class threshold
, which contains the following fields:
threshold |
data-driven threshold |
thr.mat |
thresholded input matrix |
References
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
See Also
plot.threshold, print.threshold
Examples
## Not run:
library(fnets)
out <- fnets(data.unrestricted,
var.args = list(n.cores = 2)
)
# Granger-causal network
th1 <- threshold(out$idio.var$beta)
plot(th1)
print(th1)
# Partial correlations
th2 <- threshold(out$lrpc$pc)
# Long-run partial correlations
th3 <- threshold(out$lrpc$lrpc)
## End(Not run)
Plotting output for tuning parameter selection in fnets
Description
Tuning plots for S3 objects of class fnets
.
Produces up to two plots visualising CV and IC procedures for selecting tuning parameters and the VAR order.
Usage
tuning_plot(x, ...)
Arguments
x |
|
... |
additional arguments |
Details
See Owens, Cho and Barigozzi (2024+) for further details.
Value
CV/IC plot for the VAR component, and CV plot for the lrpc component (when x$do.lrpc = TRUE
).
References
Owens, D., Cho, H. & Barigozzi, M. (2024+) fnets: An R Package for Network Estimation and Forecasting via Factor-Adjusted VAR Modelling. The R Journal (to appear).
See Also
Dantzig selector-type estimator of VAR processes via constrained l1
-minimisation
Description
Dantzig selector-type estimator of VAR processes via constrained l1
-minimisation
Usage
var.dantzig(GG, gg, lambda, symmetric = "min", n.cores = 1)
Lasso-type estimator of VAR processes via l1
-regularised M
-estimation
Description
Lasso-type estimator of VAR processes via l1
-regularised M
-estimation
Usage
var.lasso(GG, gg, lambda, symmetric = "min", n.iter = 100, tol = 0)
Cross validation for factor-adjusted VAR estimation
Description
Cross validation for factor-adjusted VAR estimation
Usage
yw.cv(
xx,
method = c("lasso", "ds"),
lambda.max = NULL,
var.order = 1,
n.folds = 1,
path.length = 10,
q = 0,
kern.bw = NULL,
n.cores = 1
)
Information criterion for factor-adjusted VAR estimation
Description
Information criterion for factor-adjusted VAR estimation
Usage
yw.ic(
xx,
method = c("lasso", "ds"),
lambda.max = NULL,
var.order = 1,
penalty = NULL,
path.length = 10,
q = 0,
kern.bw = NULL
)