chart.Histogram {PerformanceAnalytics} | R Documentation

## histogram of returns

### Description

Create a histogram of returns, with optional curve fits for density and normal. This is wrapper function for `hist`, see the help for that function for additional arguments you may wish to pass in.

### Usage

    chart.Histogram(R, breaks = "FD", main = NULL, xlab = "Returns", ylab = "Frequency", methods = c("add.density", "add.normal", "add.centered", "add.rug", "add.risk", "add.qqplot"), colorset = c("lightgray", "#00008F", "#005AFF", "#23FFDC", "#ECFF13", "#FF4A00", "#800000"), border.col = "white", box.col = "white", lwd = 2, xlim = NULL, darken = FALSE, ...)

### Arguments

`R` | a vector, matrix, data frame, timeSeries or zoo object of asset returns
`breaks` | how to calculate the breaks between the bars, one of: a vector giving the breakpoints between histogram cells, a single number giving the number of cells for the histogram, a character string naming an algorithm to compute the number of cells (see Details), a function to compute the number of cells. In the last three cases the number is a suggestion only. see `hist` for details, default "FD"
`methods` |
`main` | set the chart title, same as in `plot`
`ylab` | set the y-axis label, same as in `plot`
`xlab` | set the x-axis label, same as in `plot`
`border.col` | color to use for the border
`box.col` | color to use for the box
`xlim` | set the x-axis limit, same as in `plot`
`lwd` | set the line width, same as in `plot`
`colorset` | color palette to use, set by default to rational choices
`darken` | if true, draws the chart elements in "darkgray" rather than "gray". Makes it easier to print for some printers.
`...` | any other passthru parameters

### Details

The default for `breaks` is `"FD"`. Other names for which algorithms are supplied are `"Sturges"` (see `nclass.Sturges`), `"Scott"`, and `"FD"` / `"Freedman-Diaconis"` (with corresponding functions `nclass.scott` and `nclass.FD`). Case is ignored and partial matching is used. Alternatively, a function can be supplied which will compute the intended number of breaks as a function of `R`.

### Value

chart of histogram of returns

### Note

Code inspired by a chart on: http://zoonek2.free.fr/UNIX/48_R/03.html

### Author(s)

Peter Carl

### References

### See Also

`hist`

### Examples

        #first get some data
        data(edhec)
        #default chart is too busy
        chart.Histogram(edhec[,'Equity.Market.Neutral',drop=FALSE])

        # version with more breaks and the standard close fit density distribution
        chart.Histogram(edhec[,'Equity.Market.Neutral',drop=FALSE], breaks=40, methods = c("add.density", "add.rug") )

        chart.Histogram(edhec[,'Equity.Market.Neutral',drop=FALSE], methods = c( "add.centered") )

        # version with just the histogram and normal distribution centered on 0
        chart.Histogram(edhec[,'Equity.Market.Neutral',drop=FALSE], methods = c( "add.centered") )

        # version with histogram, normal, and close fit distribtuion
        chart.Histogram(edhec[,'Equity.Market.Neutral',drop=FALSE], methods = c( "add.centered", "add.density") )

        # add a rug to the previous plot for more granularity on precisely where the distribution fell
        chart.Histogram(edhec[,'Equity.Market.Neutral',drop=FALSE], methods = c( "add.centered", "add.density", "add.rug") )

        # now show a qqplot to give us another view on how normal the data are
        chart.Histogram(edhec[,'Equity.Market.Neutral',drop=FALSE], methods = c( "add.centered", "add.density", "add.rug", "add.qqplot") )

        # add risk measure(s) to show where those are in relation to observed returns
        chart.Histogram(edhec[,'Equity.Market.Neutral',drop=FALSE], methods = c("add.density", "add.centered", "add.rug", "add.risk") )

[Package PerformanceAnalytics version 0.9.5 Index]