chart.QQPlot: Plot a QQ chart in PerformanceAnalytics: Econometric Tools for Performance and Risk Analysis (2024)

In PerformanceAnalytics: Econometric Tools for Performance and Risk Analysis

Description Usage Arguments Details Author(s) References See Also Examples

Description

Plot the return data against any theoretical distribution.

Usage

 1 2 3 4 5 6 7 8 910111213141516171819202122232425
chart.QQPlot( R, distribution = "norm", ylab = NULL, xlab = paste(distribution, "Quantiles"), main = NULL, las = par("las"), envelope = FALSE, labels = FALSE, col = c(1, 4), lwd = 2, pch = 1, cex = 1, line = c("quartiles", "robust", "none"), element.color = "darkgray", cex.axis = 0.8, cex.legend = 0.8, cex.lab = 1, cex.main = 1, xaxis = TRUE, yaxis = TRUE, ylim = NULL, distributionParameter = NULL, ...)

Arguments

R

an xts, vector, matrix, data frame, timeSeries or zoo object ofasset returns

distribution

root name of comparison distribution - e.g., 'norm' forthe normal distribution; 't' for the t-distribution. See examples for otherideas.

ylab

set the y-axis label, as in plot

xlab

set the x-axis label, as in plot

main

set the chart title, same as in plot

las

set the direction of axis labels, same as in plot

envelope

confidence level for point-wise confidence envelope, orFALSE for no envelope.

labels

vector of point labels for interactive point identification,or FALSE for no labels.

col

color for points and lines; the default is the secondentry in the current color palette (see 'palette' and 'par').

lwd

set the line width, as in plot

pch

symbols to use, see also plot

cex

symbols to use, see also plot

line

'quartiles' to pass a line through the quartile-pairs, or'robust' for a robust-regression line; the latter uses the 'rlm' functionin the 'MASS' package. Specifying 'line = "none"' suppresses the line.

element.color

provides the color for drawing chart elements, such asthe box lines, axis lines, etc. Default is "darkgray"

cex.axis

The magnification to be used for axis annotation relative tothe current setting of 'cex'

cex.legend

The magnification to be used for sizing the legendrelative to the current setting of 'cex'

cex.lab

The magnification to be used for x- and y-axis labelsrelative to the current setting of 'cex'

cex.main

The magnification to be used for the main title relative tothe current setting of 'cex'.

xaxis

if true, draws the x axis

yaxis

if true, draws the y axis

ylim

set the y-axis limits, same as in plot

distributionParameter

a string of the parameters of the distributione.g., distributionParameter = 'location = 1, scale = 2, shape = 3, df = 4' for skew-T distribution

...

any other passthru parameters to the distribution function

Details

A Quantile-Quantile (QQ) plot is a scatter plot designed to compare the datato the theoretical distributions to visually determine if the observationsare likely to have come from a known population. The empirical quantiles areplotted to the y-axis, and the x-axis contains the values of the theoricalmodel. A 45-degree reference line is also plotted. If the empirical datacome from the population with the choosen distribution, the points shouldfall approximately along this reference line. The larger the departure fromthe reference line, the greater the evidence that the data set have comefrom a population with a different distribution.

Author(s)

John Fox, ported by Peter Carl

References

main code forked/borrowed/ported from the excellent:
Fox,John (2007) car: Companion to Applied Regression
http://socserv.socsci.mcmaster.ca/jfox/

See Also

qqplot
qq.plot
plot

Examples

 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
library(MASS) library(PerformanceAnalytics)data(managers)x = checkData(managers[,2, drop = FALSE], na.rm = TRUE, method = "vector")# Panel 1: Normal distributionchart.QQPlot(x, main = "Normal Distribution",line=c("quartiles"), distribution = 'norm', envelope=0.95)# Panel 2, Log-Normal distributionfit = fitdistr(1+x, 'lognormal')chart.QQPlot(1+x, main = "Log-Normal Distribution", envelope=0.95, distribution='lnorm',distributionParameter='meanlog = fit$estimate[[1]],  sdlog = fit$estimate[[2]]')## Not run: # Panel 3: Mixture Normal distributionlibrary(nor1mix)obj = norMixEM(x,m=2)chart.QQPlot(x, main = "Normal Mixture Distribution",line=c("quartiles"), distribution = 'norMix', distributionParameter='obj',envelope=0.95)# Panel 4: Symmetric t distributionlibrary(sn)n = length(x)fit.tSN = st.mple(as.matrix(rep(1,n)),x,symmetr = TRUE)names(fit.tSN$dp) = c("location","scale","dof")round(fit.tSN$dp,3)chart.QQPlot(x, main = "MO Symmetric t-Distribution QQPlot",xlab = "quantilesSymmetricTdistEst",line = c("quartiles"),envelope = .95, distribution = 't', distributionParameter='df=fit.tSN$dp[3]',pch = 20)# Panel 5: Skewed t distributionfit.st = st.mple(as.matrix(rep(1,n)),x)# fit.st = st.mple(y=x) Produces same result as line abovenames(fit.st$dp) = c("location","scale","skew","dof")round(fit.st$dp,3)chart.QQPlot(x, main = "MO Returns Skewed t-Distribution QQPlot",xlab = "quantilesSkewedTdistEst",line = c("quartiles"),envelope = .95, distribution = 'st',distributionParameter = 'xi = fit.st$dp[1],omega = fit.st$dp[2],alpha = fit.st$dp[3],nu=fit.st$dp[4]',pch = 20)# Panel 6: Stable Parietianlibrary(fBasics)fit.stable = stableFit(x,doplot=FALSE)chart.QQPlot(x, main = "Stable Paretian Distribution", envelope=0.95, distribution = 'stable', distributionParameter = 'alpha = fit(stable.fit)$estimate[[1]],  beta = fit(stable.fit)$estimate[[2]],  gamma = fit(stable.fit)$estimate[[3]],  delta = fit(stable.fit)$estimate[[4]], pm = 0')## End(Not run)#end examples

PerformanceAnalytics documentation built on Feb. 6, 2020, 5:11 p.m.

PerformanceAnalytics index

Package overview README.md Estimation of Higher Order Moments How to Present Tables in Plot Devices PerformanceAnalytics Charts and Tables Presentation - Meielisalp - 2007 PerformanceAnalytics Charts and Tables Reference PerformanceAnalytics Data Mining Presentation - UseR - 2007 Performance Attribution from Bacon Portfolio Returns **PerformanceAnalytics** Plotting Using Additional Plotting Engines

chart.QQPlot: Plot a QQ chart in PerformanceAnalytics: Econometric Tools for Performance and Risk Analysis (2024)
Top Articles
Latest Posts
Article information

Author: Gregorio Kreiger

Last Updated:

Views: 5987

Rating: 4.7 / 5 (77 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Gregorio Kreiger

Birthday: 1994-12-18

Address: 89212 Tracey Ramp, Sunside, MT 08453-0951

Phone: +9014805370218

Job: Customer Designer

Hobby: Mountain biking, Orienteering, Hiking, Sewing, Backpacking, Mushroom hunting, Backpacking

Introduction: My name is Gregorio Kreiger, I am a tender, brainy, enthusiastic, combative, agreeable, gentle, gentle person who loves writing and wants to share my knowledge and understanding with you.