plot.tsfm | R Documentation |
Generic plot
method for object of class tsfm
.
Plots chosen characteristic(s) for one or more assets.
## S3 method for class 'tsfm'
plot(
x,
which = NULL,
f.sub = 1:2,
a.sub = 1:6,
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,
...
)
x |
an object of class |
which |
a number to indicate the type of plot. If a subset of the plots
is required, specify a subset of the numbers 1:12 for group plots and 1:19
for individual plots. If |
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. |
plot.single |
logical; If |
asset.name |
name of the individual asset to be plotted. Is necessary
if |
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 |
las |
one of |
lwd |
set the line width, same as in |
maxlag |
optional number of lags to be calculated for ACF. Default is 15. |
... |
further arguments to be passed to other plotting functions. |
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.
CUSUM plots (individual asset plot options 15, 16 and 17) are applicable
only for fit.method="LS"
.
Modified residuals, rolling regression and single factor model plots
(individual asset plot options 4, 18 and 19) are not applicable for
variable.selection="lars"
.
The last option for plotting asset returns vs. factor returns (individual asset plot option 19 and group plot 12) are only applicable for single factor models.
Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
fitTsfm
, residuals.tsfm
,
fitted.tsfm
, fmCov.tsfm
and
summary.tsfm
for time series 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), G(3) - chart.TimeSeries
,
I(2,3,4,19), G(12) - plot.default
,
I(3,4) - panel.smooth
,
I(8,9,10) - chart.ACFplus
,
I(11,12) - plot.density
,
I(13) - chart.Histogram
,
I(14) - chart.QQPlot
,
I(15,16,17) - plot.efp
(requires strucchange package),
I(18) - plot.zoo
,
G(1,2,4,5,9,10,11) - barchart
,
G(6) - chart.Correlation
and
G(7,8) - corrplot.mixed
(requires corrplot package).
# load data
data(managers, package = 'PerformanceAnalytics')
fit.macro <- fitTsfm(asset.names = colnames(managers[,(1:6)]),
factor.names = colnames(managers[,(7:9)]),
rf.name = "US 3m TR",
data = managers)
# 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.macro)
# choose specific plot option(s) using which
# plot the first 2 factor betas of first 4 assets fitted above
plot(fit.macro, f.sub=1:2, a.sub=1:4, which=2)
# plot factor model residuals scatterplot matrix, with histograms, density
# overlays, correlations and significance stars
plot(fit.macro, 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.macro, plot.single=TRUE, asset.name="HAM1", which=13)
# for individual plots, the "which" argument specifies plot type.
# Plots 15:17 require the suggested "strucchange" package.
# 17 plots the Recursive estimates (RE) test of LS regression coefficients.
require(strucchange)
plot(fit.macro, plot.single=TRUE, asset.name="HAM1", which=17)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.