fitStatisticalFactorModel: Fit statistical factor model using principle components...

Description Usage Arguments Value Author(s) References Examples

Description

Fit statistical factor model using principle components. This function is mainly adapted from S+FinMetric function mfactor.

Usage

1
2
  fitStatisticalFactorModel(data, k = 1, refine = TRUE,
    check = FALSE, max.k = NULL, sig = 0.05, na.rm = FALSE)

Arguments

data

a vector, matrix, data.frame, xts, timeSeries or zoo object with asset returns and factors retunrs names. If data does not have xts class, rownames must provide xts compatible time index.

k

numbers of factors if it is scalar or method of choosing optimal number of factors. "bn" represents Bai and Ng (2002) method and "ck" represents Connor and korajczyk (1993) method. Default is k = 1.

refine

TRUE By default, the APCA fit will use the Connor-Korajczyk refinement.

check

check if some variables has identical values. Default is FALSE.

max.k

scalar, select the number that maximum number of factors to be considered.

sig

significant level when ck method uses.

na.rm

if allow missing values. Default is FALSE.

Value

Author(s)

Eric Zivot and Yi-An Chen

References

Zivot and Wang, (2006) "Modeling Financial Time Series with S-PLUS, 2nd edition"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# load data for fitStatisticalFactorModel.r
# data from finmetric berndt.dat and folio.dat

data(stat.fm.data)
##
# sfm.dat is for pca
# sfm.apca.dat is for apca
class(sfm.dat)
class(sfm.apca.dat)

# pca
args(fitStatisticalFactorModel)
sfm.pca.fit <- fitStatisticalFactorModel(sfm.dat,k=2)
class(sfm.pca.fit)
names(sfm.pca.fit)
sfm.pca.fit$factors
sfm.pca.fit$loadings
sfm.pca.fit$r2
sfm.pca.fit$residuals
sfm.pca.fit$resid.variance
sfm.pca.fit$mimic
# apca
sfm.apca.fit <- fitStatisticalFactorModel(sfm.apca.dat,k=1)
names(sfm.apca.fit)
sfm.apca.res <- sfm.apca.fit$residuals
sfm.apca.mimic <- sfm.apca.fit$mimic
# apca with bai and Ng method
sfm.apca.fit.bn <- fitStatisticalFactorModel(sfm.apca.dat,k="bn")
class(sfm.apca.fit.bn)
names(sfm.apca.fit.bn)
sfm.apca.fit.bn$mimic

# apca with ck method
sfm.apca.fit.ck <- fitStatisticalFactorModel(sfm.apca.dat,k="ck")
class(sfm.apca.fit.ck)
names(sfm.apca.fit.ck)
sfm.apca.fit.ck$mimic

R-Finance/FactorAnalytics documentation built on May 8, 2019, 3:51 a.m.