Statistics & Data Manipulation

Means

Moments

PerformanceAnalytics.kurtFunction
kurt(R, method="simple")

Calculates the kurtosis of a series.

Methods:

  • population
  • excess (population - 3)
  • sample
  • sampleexcess (sample - 3)
  • fisher
source
PerformanceAnalytics.covarianceFunction
covariance(Ra::AbstractArray{<:Number},Rb::AbstractArray{<:Number};corrected::Bool=false)

Calculates the CoVariance of two asset returns.

\[CoVariance(R_a,R_b) = \sum_{i=1}^n([R_a - \overline{R_a}] \times [R_b - \overline{R_b}]) \times\frac{1}{n}\]

If corrected=true

\[CoVariance(R_a,R_b) = \sum_{i=1}^n([R_a - \overline{R_a}] \times [R_b - \overline{R_b}]) \times\frac{1}{n-1}\]

source
covariance(Ra::AssetReturn,Rb::AssetReturn;corrected::Bool=false)

Calculates the CoVariance of two asset returns.

source
PerformanceAnalytics.coskewFunction
coskew(Ra::AbstractArray{<:Number},Rb::AbstractArray{<:Number})

Calculates the CoSkewness of returns. Note that coskew(x,y) != coskew(y,x).

\[Coskew(r_a,r_b) = \frac{cov(r_a,(r_b-\overline{r_b})^2)}{\sum_{i=1}^n(r_b - \overline{r_b})^3\times\frac{1}{n}}\]

source
coskew(Ra::AssetReturn,Rb::AssetReturn)

Calculates the CoSkewness of returns.

source
PerformanceAnalytics.cokurtFunction
cokurt(Ra::AbstractArray{<:Number},Rb::AbstractArray{<:Number})

Calculates the symmetric CoKurtosis of two returns (i.e. Cokurt(Ra,Ra,Rb,Rb))

\[CoKurtosis(r_a,r_b) = \frac{\frac{1}{n}\times\sum_{t=1}^n[(r_a - \overline{r_a})^2\times(r_b - \overline{r_b})^2]}{\sigma^2_{r_a}\times\sigma^2_{r_b}}\]

source
cokurt(Ra::AssetReturn,Rb::AssetReturn)

Calculates the symmetric CoKurtosis of two returns (i.e. Cokurt(Ra,Ra,Rb,Rb))

source

Regression Based

PerformanceAnalytics.factor_loadingsFunction
factor_loadings(Y::AbstractArray{<:Number},X::AbstractArray{<:Number}...;intercept::Bool=true)

Returns the factor loadings (beta estimates) of a (factor) regression.

source

Calculating Returns

PerformanceAnalytics.roll_applyFunction
roll_apply(data::AbstractVector{<:Number}...;fun::Function, window::Int,retain_length::Bool=false,fill_with = NaN,always_return::Bool=false)

Applies a fun::Function over a rolling window.

Arguments:

  • data::AbstractArray{<:Number}: one or multiple arrays.
  • fun::Function: the function to be applied. Has to return a single value (not a Vector of values).
  • window::Int: the window length.
  • retain_length::Bool: whether to original length of the data provided should be retained. If true fills the observations that could not be calculated with fill_with.
  • fill_with: The value that should be returned for values that could not be calculated.
  • always_return::Bool: returns a vector with fill_with equal to the initial data length if the window is longer than the length of the input data.
source