Last data update: 2014.03.03

R: Asymptotic PCA
apcaR Documentation

Asymptotic PCA

Description

Asymptotic Principal Components Analysis for a fixed number of factors

Usage

apca(x,nf)

Arguments

x

a numeric matrix or other object for which 'as.matrix' will produce a numeric matrix.

nf

number of factors desired

Details

NOTE: This is a preliminary version of this function, and it may be modified in the future.

Value

A list with four components:

eig

eigenvalues

factors

estimated factor scores

loadings

estimated factor loadings

rsq

R-squared from the regression of each variable on the factor space

Author(s)

Ruey Tsay

References

Ruey Tsay (2005) Analysis of Financial Time Series, 2nd ed. (Wiley, sec. 9.6, pp. 436-440)

See Also

princomp

Examples

# Consider the monthly simple returns of 40 stocks on NYSE and NASDAQ
# from 2001 to 2003 with 36 observations.
data(m.apca0103)
dim(m.apca0103)
M.apca0103 <- with(m.apca0103, array(return, dim=c(36, 40), dimnames=
          list(as.character(date[1:36]),
               paste("Co", CompanyID[seq(1, 1440, 36)], sep=""))))

# The traditional PCA is not applicable to estimate the factor model
# because of the singularity of the covariance matrix.  The asymptotic
# PCA provides an approach to estimate factor model based on asymptotic
# properties. For the simple example considered, the sample size is
# $T$ = 36 and the dimension is $k$ = 40. If the number of factor is
# assumed to be 1, the APCA gives a summary of the factor loadings as
# below:
#
apca40 <- apca(M.apca0103, 1)
#
# (min, 1st Quartile, median, mean, 3rd quartile, max) =
# (0.069, 0.432, 0.629, 0.688, 1.071, 1.612).
#
# Note that the sign of any loading vector is not uniquely determined
# in the same way as the sign of an eigenvector is not uniquely
# determined. The output also contains the summary statistics of the
# R-squares of individual returns, i.e. the R-squares measuring the
# total variation of individual return explained by the factors. For
# the simple case considered, the summary of R-squares is (min, 1st
# Quartile, median, mean, 3rd quartile, max) =
# (0.090,0.287,0.487,0.456,0.574,0.831).

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(FinTS)
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/FinTS/apca.Rd_%03d_medium.png", width=480, height=480)
> ### Name: apca
> ### Title: Asymptotic PCA
> ### Aliases: apca
> ### Keywords: ts
> 
> ### ** Examples
> 
> # Consider the monthly simple returns of 40 stocks on NYSE and NASDAQ
> # from 2001 to 2003 with 36 observations.
> data(m.apca0103)
> dim(m.apca0103)
[1] 1440    3
> M.apca0103 <- with(m.apca0103, array(return, dim=c(36, 40), dimnames=
+           list(as.character(date[1:36]),
+                paste("Co", CompanyID[seq(1, 1440, 36)], sep=""))))
> 
> # The traditional PCA is not applicable to estimate the factor model
> # because of the singularity of the covariance matrix.  The asymptotic
> # PCA provides an approach to estimate factor model based on asymptotic
> # properties. For the simple example considered, the sample size is
> # $T$ = 36 and the dimension is $k$ = 40. If the number of factor is
> # assumed to be 1, the APCA gives a summary of the factor loadings as
> # below:
> #
> apca40 <- apca(M.apca0103, 1)
Asymptotic PCA:  Extracting 1 factors from 36 observations on 40 series

Factor Loading: Summary
    factor     min 1st Qu. median   mean    Q3   max
F.1      1 0.06947  0.4322 0.6286 0.6883 1.071 1.612
R-squared: Summary
    min 1st Qu.  median    mean      Q3     max 
0.01733 0.21922 0.47494 0.43715 0.57393 0.82652 
> #
> # (min, 1st Quartile, median, mean, 3rd quartile, max) =
> # (0.069, 0.432, 0.629, 0.688, 1.071, 1.612).
> #
> # Note that the sign of any loading vector is not uniquely determined
> # in the same way as the sign of an eigenvector is not uniquely
> # determined. The output also contains the summary statistics of the
> # R-squares of individual returns, i.e. the R-squares measuring the
> # total variation of individual return explained by the factors. For
> # the simple case considered, the summary of R-squares is (min, 1st
> # Quartile, median, mean, 3rd quartile, max) =
> # (0.090,0.287,0.487,0.456,0.574,0.831).
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>