## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(convergenceDFM)

## ----example, eval=FALSE------------------------------------------------------
# set.seed(123)
# X <- matrix(rnorm(120 * 8), 120, 8)               # labour-value price indices
# Y <- X + matrix(rnorm(120 * 8, 0, 0.5), 120, 8)   # market price indices
# 
# res <- run_complete_factor_analysis_robust(
#   X_matrix = X, Y_matrix = Y,
#   max_comp = 3, dfm_lags = 1,
#   skip_ou  = TRUE,
#   make_plots = FALSE,
#   verbose  = FALSE
# )
# 
# res$dfm$r2_global        # in-sample fit of the factor VAR
# res$dfm$half_life_dominant

## ----coupling, eval=FALSE-----------------------------------------------------
# null <- run_rotation_null_on_results(res, B = 500, seed = 1,
#                                      null_method = "circular_shift")
# null$p_values        # Monte Carlo one-sided p-values
# null$p_values_fdr    # Benjamini-Hochberg adjusted

## ----oos, eval=FALSE----------------------------------------------------------
# dr <- deltaR2_ou(res, lag = 1, oos = TRUE, seed = 1, verbose = FALSE)
# dr$OOS$delta_r2_oos
# dr$OOS$cw_p          # Clark-West p-value

