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 x

q.max

maximum number of factors; if q.max = NULL, a default value is selected as min(50, floor(sqrt(min(dim(x)[2] - 1, dim(x)[1]))))

center

whether to de-mean the input x row-wise

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

fnets 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 fc.restricted = TRUE; possible values are:

"ic"

information criteria of Alessi, Barigozzi & Capasso (2010))

"er"

eigenvalue ratio of Ahn & Horenstein (2013)

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 h (with each column representing a variable)

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 = NULL, the factor number is estimated by an information criterion-based approach of Hallin and Liška (2007)

q.method

A string specifying the factor number selection method; possible values are:

"ic"

information criteria-based methods of Alessi, Barigozzi & Capasso (2010) when fm.restricted = TRUE or Hallin and Liška (2007) when fm.restricted = FALSE

"er"

eigenvalue ratio of Ahn and Horenstein (2013)

ic.op

choice of the information criterion penalty. Currently the three options from 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

kern.bw

a positive integer specifying the kernel bandwidth for dynamic PCA; by default, it is set to floor(4 *(dim(x)[2]/log(dim(x)[2]))^(1/3)))

mm

bandwidth

Value

a list containing

q

number of factors

q.method.out

if q = NULL, the output from the chosen q.method, either a vector of eigenvalue ratios or hl.factor.number

spec

a list containing the estimates of the spectral density matrices for x, common and idiosyncratic components

acv

a list containing estimates of the autocovariance matrices for x, common and idiosyncratic components

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:

"ic"

information criteria-based methods of Alessi, Barigozzi & Capasso (2010) when fm.restricted = TRUE or Hallin and Liška (2007) when fm.restricted = FALSE

"er"

eigenvalue ratio of Ahn and Horenstein (2013) when fm.restricted = TRUE or Avarucci et al. (2022) when fm.restricted = FALSE

q.max

maximum number of factors; if q.max = NULL, a default value is selected as min(50, floor(sqrt(min(dim(x)[2] - 1, dim(x)[1]))))

center

whether to de-mean the input x

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 x

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:

"ic"

information criteria-based methods of Alessi, Barigozzi & Capasso (2010) when fm.restricted = TRUE or Hallin and Liška (2007) when fm.restricted = FALSE

"er"

eigenvalue ratio of Ahn and Horenstein (2013) when fm.restricted = TRUE or Avarucci et al. (2022) when fm.restricted = FALSE

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 floor(4 *(dim(x)[2]/log(dim(x)[2]))^(1/3))). When fm.restricted = TRUE, it is used to compute the number of lags for which autocovariance matrices are estimated

common.args

a list specifying the tuning parameters required for estimating the impulse response functions and common shocks. It contains:

factor.var.order

order of the blockwise VAR representation of the common component. If factor.var.order = NULL, it is selected blockwise by Schwarz criterion

max.var.order

maximum blockwise VAR order for the Schwarz criterion

trunc.lags

truncation lag for impulse response function estimation

n.perm

number of cross-sectional permutations involved in impulse response function estimation

var.order

order of the idiosyncratic VAR process; if a vector of integers is supplied, the order is chosen via tuning

var.method

a string specifying the method to be adopted for idiosyncratic VAR process estimation; possible values are:

"lasso"

Lasso-type l1-regularised M-estimation

"ds"

Dantzig Selector-type constrained l1-minimisation

var.args

a list specifying the tuning parameters required for estimating the idiosyncratic VAR process. It contains:

n.iter

maximum number of descent steps, by default depends on var.order; applicable when var.method = "lasso"

n.cores

number of cores to use for parallel computing, see makePSOCKcluster; applicable when var.method = "ds"

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:

tuning

a string specifying the selection procedure for var.order and lambda; possible values are: "cv" for cross validation, and "bic" for information criterion

n.folds

if tuning = "cv", positive integer number of folds

penalty

if tuning = "bic", penalty multiplier between 0 and 1; if penalty = NULL, it is set to 1/(1+exp(dim(x)[1])/dim(x)[2]))

by default

path.length

positive integer number of regularisation parameter values to consider; a sequence is generated automatically based in this value

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 fm.restricted = FALSE a list containing estimates of the spectral density matrices for x, common and idiosyncratic components

acv

a list containing estimates of the autocovariance matrices for x, common and idiosyncratic components

loadings

if fm.restricted = TRUE, factor loadings; if fm.restricted = FALSE and q >= 1, a list containing estimators of the impulse response functions (as an array of dimension (p, q, trunc.lags + 2))

factors

if fm.restricted = TRUE, factor series; else, common shocks (an array of dimension (q, n))

idio.var

a list containing 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

regularisation parameter

var.order

VAR order

lrpc

see the output of par.lrpc

mean.x

if center = TRUE, returns a vector containing row-wise sample means of x; if center = FALSE, returns a vector of zeros

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 x

fm.restricted

whether to estimate a restricted factor model using static PCA

q

Either a string specifying the factor number selection method when fm.restricted = TRUE; possible values are:

"ic"

information criteria-based methods of Alessi, Barigozzi & Capasso (2010) when fm.restricted = TRUE or Hallin and Liška (2007) when fm.restricted = FALSE

"er"

eigenvalue ratio of Ahn and Horenstein (2013) when fm.restricted = TRUE or Avarucci et al. (2022) when fm.restricted = FALSE

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 floor(4 *(dim(x)[2]/log(dim(x)[2]))^(1/3))). When fm.restricted = TRUE, it is used to compute the number of lags for which autocovariance matrices are estimated

common.args

a list specifying the tuning parameters required for estimating the impulse response functions and common shocks. It contains:

factor.var.order

order of the blockwise VAR representation of the common component. If factor.var.order = NULL, it is selected blockwise by Schwarz criterion

max.var.order

maximum blockwise VAR order for the Schwarz criterion

trunc.lags

truncation lag for impulse response function estimation

n.perm

number of cross-sectional permutations involved in impulse response function estimation

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 fm.restricted = FALSE a list containing estimates of the spectral density matrices for x, common and idiosyncratic components

acv

a list containing estimates of the autocovariance matrices for x, common and idiosyncratic components

loadings

if fm.restricted = TRUE, factor loadings; if fm.restricted = FALSE and q >= 1, a list containing estimators of the impulse response functions (as an array of dimension (p, q, trunc.lags + 2))

factors

if fm.restricted = TRUE, factor series; else, common shocks (an array of dimension (q, n))

mean.x

if center = TRUE, returns a vector containing row-wise sample means of x; if center = FALSE, returns a vector of zeros

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

print.fm, predict.fm

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 x

method

a string specifying the method to be adopted for VAR process estimation; possible values are:

"lasso"

Lasso-type l1-regularised M-estimation

"ds"

Dantzig Selector-type constrained l1-minimisation

lambda

l1-regularisation parameter; if lambda = NULL, tuning is employed to select the parameter

var.order

order of the VAR process; if a vector of integers is supplied, the order is chosen via tuning

tuning.args

a list specifying arguments for tuning for selecting the regularisation parameter (and VAR order). It contains:

tuning

a string specifying the selection procedure for var.order and lambda; possible values are: "cv" for cross validation, and "bic" for information criterion

n.folds

if tuning = "cv", positive integer number of folds

penalty

if tuning = "bic", penalty multiplier between 0 and 1; if penalty = NULL, it is set to 1/(1+exp(dim(x)[1])/dim(x)[2]))

by default

path.length

positive integer number of regularisation parameter values to consider; a sequence is generated automatically based in this value

do.threshold

whether to perform adaptive thresholding of VAR parameter estimator with threshold

n.iter

maximum number of descent steps, by default depends on var.order; applicable when method = "lasso"

tol

numerical tolerance for increases in the loss function; applicable when method = "lasso"

n.cores

number of cores to use for parallel computing, see makePSOCKcluster; applicable when method = "ds"

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

l1-regularisation parameter

var.order

VAR order

mean.x

if center = TRUE, returns a vector containing row-wise sample means of x; if center = FALSE, returns a vector of zeros

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 q.max = NULL, a default value is selected as min(50, floor(sqrt(min(dim(x)[2] - 1, dim(x)[1]))))

mm

a positive integer specifying the kernel bandwidth for dynamic PCA; by default, it is set to floor(4 *(dim(x)[2]/log(dim(x)[2]))^(1/3)))

center

whether to de-mean the input x row-wise

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

fnets 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 h (with each column representing a variable)

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

network.fnets


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

fnets object

type

a string specifying which of the above three networks (i)–(iii) to visualise; possible values are

"granger"

directed network representing Granger causal linkages

"pc"

undirected network representing contemporaneous linkages; available when object$do.lrpc = TRUE

"lrpc"

undirected network summarising Granger causal and contemporaneous linkages; available when x$do.lrpc = TRUE

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 groups

...

additional arguments to igraph::graph_from_adjacency_matrix

Value

a list containing

network

igraph object

names

input argument

groups

input argument

grp.col

vector of colours corresponding to each node

...

additional arguments to igraph::graph_from_adjacency_matrix

See Also

fnets, plot.fnets

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

fnets object

eta

l1-regularisation parameter; if eta = NULL, it is selected by cross validation

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:

n.folds

positive integer number of folds

path.length

positive integer number of regularisation parameter values to consider; a sequence is generated automatically based in this value

lrpc.adaptive

whether to use the adaptive estimation procedure

eta.adaptive

l1-regularisation parameter for Step 1 of the adaptive estimation procedure; if eta.adaptive = NULL, the default choice is 2 * sqrt(log(dim(x)[1])/dim(x)[2])

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 Delta and Omega parameter estimators with threshold

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

l1-regularisation parameter

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

factor.number object

...

not used

Value

NULL, printed to console

See Also

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)

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

fnets object

type

a string specifying which of the above three networks (i)–(iii) to visualise when display = "network" or display = "heatmap"; possible values are

"granger"

directed network representing Granger causal linkages

"pc"

undirected network representing contemporaneous linkages; available when x$do.lrpc = TRUE

"lrpc"

undirected network summarising Granger causal and contemporaneous linkages; available when x$do.lrpc = TRUE

display

a string specifying which plot to produce; possible values are

"network"

visualise the network as an igraph object, see plot.igraph

"heatmap"

visualise the network as a heatmap, see imagePlot

"tuning"

visualise the outcome from CV or IC (specified by tuning.args$tuning of fnets) for selecting l1-regularisation parameters and the VAR order

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 groups

...

additional arguments

Value

A plot produced as per the input arguments

See Also

fnets

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

threshold object

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

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)

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

fm object

n.ahead

forecasting horizon

fc.restricted

if fc.restricted = TRUE, the forecast is generated under a restricted factor model

r

number of static factors, or a string specifying the factor number selection method when fc.restricted = TRUE; possible values are:

"ic"

information criteria of Alessi, Barigozzi & Capasso (2010)

"er"

eigenvalue ratio of Ahn & Horenstein (2013)

...

not used

Value

a list containing

is

in-sample predictions

forecast

forecasts for the given forecasting horizon

r

factor number

See Also

fnets.factor.model

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

fnets object

newdata

input time series matrix; by default, uses input to object. Valid only for the case where newdata is modelled as a VAR process without any factors

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 fc.restricted = TRUE; possible values are:

"ic"

information criteria of Alessi, Barigozzi & Capasso (2010)

"er"

eigenvalue ratio of Ahn & Horenstein (2013)

...

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

mean.x argument from object

See Also

fnets

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

factor.number object

...

not used

Value

NULL, printed to console

See Also

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)

Print factor model

Description

Prints a summary of a fm object

Usage

## S3 method for class 'fm'
print(x, ...)

Arguments

x

fm object

...

not used

Value

NULL, printed to console

See Also

fnets.factor.model

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

fnets object

...

not used

Value

NULL, printed to console

See Also

fnets

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

threshold object

...

not used

Value

NULL, printed to console

See Also

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)

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 2 * q

heavy

if heavy = FALSE, common shocks are generated from rnorm whereas if heavy = TRUE, from rt with df = 5 and then scaled by sqrt(3 / 5)

Value

a list containing

data

ts object with n rows and p columns

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 heavy = FALSE, common shocks are generated from rnorm whereas if heavy = TRUE, from rt with df = 5 and then scaled by sqrt(3 / 5)

Value

a list containing

data

ts object with n rows and p columns

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 = TRUE

heavy

if heavy = FALSE, common shocks are generated from rnorm whereas if heavy = TRUE, from rt with df = 5 and then scaled by sqrt(3 / 5)

Value

a list containing

data

ts object with n rows and p columns

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

fnets object

...

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

fnets


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
)