| speci.factors | R Documentation |
Determines the number of factors in an approximate factor model
for a data panel, where both dimensions (T \times KN) are large,
and calculates the factor time series and corresponding list of N idiosyncratic components.
See Corona et al. (2017) for an overview and further details.
speci.factors(
L.data,
k_max = 20,
n.iterations = 4,
differenced = FALSE,
centered = FALSE,
scaled = FALSE,
n.factors = NULL
)
L.data |
List of |
k_max |
Integer. The maximum number of factors to consider. |
n.iterations |
Integer. Number of iterations for the Onatski criterion. |
differenced |
Logical. If |
centered |
Logical. If |
scaled |
Logical. If |
n.factors |
Integer. A presumed number of factors under which the idiosyncratic component |
If differenced is TRUE, the approximate factor model is estimated as proposed by Bai, Ng (2004).
If all data transformations are selected, the estimation results are identical
to the objects in $CSD for PANIC analyses in 'pcoint' objects.
A list of class 'speci', which contains the elements:
eigenvals |
Data frame. The eigenvalues of the PCA, which have been used to calculate the criteria, and their respective share on the total variance in the data panel. |
Ahn |
Matrix. The eigenvalue ratio |
Onatski |
Matrix. The calibrated threshold |
Bai |
Array. The values of the criteria |
selection |
List of the optimal number of common factors:
(1) A matrix of |
Ft |
Matrix. The common factors of dimension |
LAMBDA |
Matrix. The loadings of dimension |
L.idio |
List of |
args_speci |
List of characters and integers indicating the specifications that have been used. |
Ahn, S., and Horenstein, A. (2013): "Eigenvalue Ratio Test for the Number of Factors", Econometrica, 81, pp. 1203-1227.
Bai, J. (2004): "Estimating Cross-Section Common Stochastic Trends in Nonstationary Panel Data", Journal of Econometrics, 122, pp. 137-183.
Bai, J., and Ng, S. (2002): "Determining the Number of Factors in Approximate Factor Models", Econometrica, 70, pp. 191-221.
Bai, J., and Ng, S. (2004): "A PANIC Attack on Unit Roots and Cointegration", Econometrica, 72, pp. 1127-117.
Corona, F., Poncela, P., and Ruiz, E. (2017): "Determining the Number of Factors after Stationary Univariate Transformations", Empirical Economics, 53, pp. 351-372.
Onatski, A. (2010): "Determining the Number of Factors from Empirical Distribution of Eigenvalues", Review of Econometrics and Statistics, 92, pp. 1004-1016.
Other specification functions:
speci.VAR()
### reproduce Oersal,Arsova 2017:67, Ch.5 ###
data("MERM")
names_k = colnames(MERM)[-(1:2)] # variable names
names_i = levels(MERM$id_i) # country names
L.data = sapply(names_i, FUN=function(i)
ts(MERM[MERM$id_i==i, names_k], start=c(1995, 1), frequency=12),
simplify=FALSE)
R.fac1 = speci.factors(L.data, k_max=20, n.iterations=4)
R.fac0 = speci.factors(L.data, k_max=20, n.iterations=4,
differenced=TRUE, centered=TRUE, scaled=TRUE, n.factors=8)
# scree plot #
library("ggplot2")
pal = c("#999999", RColorBrewer::brewer.pal(n=8, name="Spectral"))
lvl = levels(R.fac0$eigenvals$scree)
F.scree = ggplot(R.fac0$eigenvals[1:20, ]) +
geom_col(aes(x=n, y=share, fill=scree), color="black", width=0.75) +
scale_fill_manual(values=pal, breaks=lvl, guide="none") +
labs(x="Component number", y="Share on total variance", title=NULL) +
theme_bw()
plot(F.scree)
# factor plot (comp. Oersal,Arsova 2017:71, Fig.4) #
library("ggfortify")
Ft = ts(R.fac0$Ft, start=c(1995, 1), frequency=12)
F.factors = autoplot(Ft, facets=FALSE, size=1.5) +
scale_color_brewer(palette="Spectral") +
labs(x="Year", y=NULL, color="Factor", title=NULL) +
theme_bw()
plot(F.factors)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.