plot.sfm: Plots from a fitted statistical factor model

Description Usage Arguments Details Author(s) See Also Examples

Description

Generic plot method for object of class sfm. Plots chosen characteristic(s) for one or more assets.

Usage

1
2
3
4
5
6
## S3 method for class 'sfm'
plot(x, which = NULL, f.sub = 1:2, a.sub = 1:6, n.top = 3,
  plot.single = FALSE, asset.name, colorset = c("royalblue", "dimgray",
  "olivedrab", "firebrick", "goldenrod", "mediumorchid", "deepskyblue",
  "chocolate", "darkslategray"), legend.loc = "topleft", las = 1, lwd = 2,
  maxlag = 15, eig.max = 0.9, cum.var = TRUE, ...)

Arguments

x

an object of class sfm produced by fitSfm.

which

a number to indicate the type of plot. If a subset of the plots is required, specify a subset of the numbers 1:13 for group plots and 1:18 for individual plots. If which=NULL (default), the following menu appears:

For plots of a group of assets:
1 = Screeplot of eigenvalues,
2 = Time series plot of estimated factors,
3 = Estimated factor loadings,
4 = Histogram of R-squared,
5 = Histogram of residual volatility,
6 = Factor model residuals scatterplot matrix, with histograms, density overlays, correlations and significance stars,
7 = Factor model residual correlation
8 = Factor model return correlation,
9 = Factor contribution to SD,
10 = Factor contribution to ES,
11 = Factor contribution to VaR,
12 = Factor mimicking portfolio weights - top long and short positions in each factor,
13 = Asset correlations - top long and short positions in each factor

For individual asset plots:
1 = Actual and fitted,
2 = Actual vs fitted,
3 = Residuals vs fitted,
4 = Sqrt. of modified residuals vs fitted,
5 = Residuals with standard error bands,
6 = Time series of squared residuals,
7 = Time series of absolute residuals,
8 = SACF and PACF of residuals,
9 = SACF and PACF of squared residuals,
10 = SACF and PACF of absolute residuals,
11 = Non-parametric density of residuals with normal overlaid,
12 = Non-parametric density of residuals with skew-t overlaid,
13 = Histogram of residuals with non-parametric density and normal overlaid,
14 = QQ-plot of residuals,
15 = CUSUM test-Recursive residuals,
16 = CUSUM test-LS residuals,
17 = Recursive estimates (RE) test of LS regression coefficients,
18 = Rolling regression over a 24-period observation window

f.sub

numeric/character vector; subset of indexes/names of factors to include for group plots. Default is 1:2.

a.sub

numeric/character vector; subset of indexes/names of assets to include for group plots. At least 2 assets must be selected. Default is 1:6.

n.top

scalar; number of largest and smallest weights to display for each factor mimicking portfolio. Default is 3.

plot.single

logical; If TRUE plots the characteristics of an individual asset's factor model. The type of plot is given by which. Default is FALSE.

asset.name

name of the individual asset to be plotted. Is necessary if x contains multiple asset fits and plot.single=TRUE.

colorset

color palette to use for all the plots. The 1st element will be used for individual time series plots or the 1st object plotted, the 2nd element for the 2nd object in the plot and so on.

legend.loc

places a legend into one of nine locations on the chart: "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", or "center". Default is "bottomright". Use legend.loc=NULL to suppress the legend.

las

one of 0, 1, 2, 3 to set the direction of axis labels, same as in plot. Default is 1.

lwd

set the line width, same as in plot. Default is 2.

maxlag

optional number of lags to be calculated for ACF. Default is 15.

eig.max

scalar in (0,1] for limiting the screeplot to factors that explain a given percent of the variance. Default is 0.9.

cum.var

logical; If TRUE, the cumulative fraction of the variance is printed above each bar in the screeplot of eigenvalues. Default is TRUE.

...

further arguments to be passed to other plotting functions.

Details

The function can be used for group plots and individual plots. User can select the type of plot either from the menu prompt (default) or directly via argument which.

In case multiple plots are needed, the menu is repeated after each plot (enter 0 to exit). User can also input a numeric vector of plot options via which.

Group plots are the default. The selected assets in a.sub and selected factors in f.sub are plotted depending on the characteristic chosen. The default is to show the first 2 factors and first 6 assets.

Setting plot.single=TRUE enables individual plots. If there is more than one asset fit by x, asset.name should be specified. In case the tsfm object x contains only a single asset fit, plot.tsfm can infer asset.name without user input.

Author(s)

Eric Zivot, Yi-An Chen and Sangeetha Srinivasan

See Also

fitSfm, residuals.sfm, fitted.sfm, fmCov.sfm and summary.sfm for statistical factor model fitting and related S3 methods. Refer to fmSdDecomp, fmEsDecomp, fmVaRDecomp for factor model risk measures.

Here is a list of plotting functions used. (I=individual, G=Group) I(1,5,6,7) - chart.TimeSeries, I(2,3,4) - plot.default, I(3,4) - panel.smooth, I(8,9,10) - chart.ACFplus, I(11,12) - plot.density, I(13), G(4,5) - chart.Histogram, I(14) - chart.QQPlot, I(15,16,17) - plot.efp, I(18) - plot.zoo, G(1,12) - barplot, G(2) - xyplot, G(3,9,10,11) - barchart, G(6) - chart.Correlation and G(7,8,13) - corrplot.mixed.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# load data from the database
data(StockReturns)

# APCA with number of factors, k=15
fit.apca <- fitSfm(r.W, k=15, refine=TRUE)

# for group plots (default), user can select plot option from menu prompt
# menu is repeated to get multiple types of plots based on the same fit
# plot(fit.apca)

# choose specific plot option(s) using which
# plot the first 4 factor betas of the first 4 assets fitted above
plot(fit.apca, f.sub=1:4, a.sub=1:4, which=3)

# plot factor model residuals scatterplot matrix, with histograms, density 
# overlays, correlations and significance stars
plot(fit.apca, which=6)

# for individual plots: set plot.single=TRUE and specify asset.name
# histogram of residuals from an individual asset's factor model fit 
plot(fit.apca, plot.single=TRUE, asset.name="AFL", which=13)

factorAnalytics documentation built on April 15, 2017, 11:18 a.m.