Statistics & Data Manipulation
Means
PerformanceAnalytics.mean_arith
— Functionmean_arith(x)
Calculates the arithmetic mean of a series.
PerformanceAnalytics.mean_geo
— Functionmean_geo(returns::Vector{Float64})
Calculates the geometric mean of a series.
Moments
PerformanceAnalytics.varp
— Functionvarp(x)
Calculates the population variance of a series.
PerformanceAnalytics.vars
— Functionvars(x)
Calculates the population standard deviation of a series.
PerformanceAnalytics.stdvp
— Functionstdvp(x)
Calculates the sample variance of a series.
PerformanceAnalytics.stdvs
— Functionstdvs(x)
Calculates the sample standard deviation of a series.
PerformanceAnalytics.skew
— Functionskew(R, method="simple")
Calculates the skewness of a series.
Methods:
- Population
- Sample
- Fisher
PerformanceAnalytics.kurt
— Functionkurt(R, method="simple")
Calculates the kurtosis of a series.
Methods:
- population
- excess (population - 3)
- sample
- sampleexcess (sample - 3)
- fisher
PerformanceAnalytics.covariance
— Functioncovariance(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}\]
covariance(Ra::AssetReturn,Rb::AssetReturn;corrected::Bool=false)
Calculates the CoVariance of two asset returns.
PerformanceAnalytics.coskew
— Functioncoskew(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}}\]
coskew(Ra::AssetReturn,Rb::AssetReturn)
Calculates the CoSkewness of returns.
PerformanceAnalytics.cokurt
— Functioncokurt(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}}\]
cokurt(Ra::AssetReturn,Rb::AssetReturn)
Calculates the symmetric CoKurtosis of two returns (i.e. Cokurt(Ra,Ra,Rb,Rb))
Regression Based
PerformanceAnalytics.factor_regression
— Functionfactor_regression(Y::AbstractArray{<:Number},X::AbstractArray{<:Number}...;intercept::Bool=true)
Returns alpha and beta estimates of a regression.
PerformanceAnalytics.factor_alpha
— Functionfactor_alpha(Y::AbstractArray{<:Number},X::AbstractArray{<:Number}...)
Returns the α (intercept) of a (factor) regression.
PerformanceAnalytics.factor_loadings
— Functionfactor_loadings(Y::AbstractArray{<:Number},X::AbstractArray{<:Number}...;intercept::Bool=true)
Returns the factor loadings (beta estimates) of a (factor) regression.
PerformanceAnalytics.factor_resid
— Functionfactor_resid(Y::AbstractArray{<:Number},X::AbstractArray{<:Number}...;intercept::Bool=true)
Returns the residuals of a (factor) regression.
Calculating Returns
PerformanceAnalytics.pct_change
— Functionpct_change(x)
Returns the percent change of an array. (Calculates returns from a price series)
PerformanceAnalytics.log_diff
— Functionlog_diff(x)
Returns the logarithmic difference. (Calculates log returns from a price series)
PerformanceAnalytics.simple_diff
— Functionsimple_diff(x)
Returns the difference. (Calculates the absolut price change)
PerformanceAnalytics.annualize
— Functionannualize(R::Number,scale::Float64=252)
Annualizes the return using the scaling factor.
annualize(R::AssetReturn)
Annualizes the return.
PerformanceAnalytics.roll_apply
— Functionroll_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 withfill_with
.fill_with
: The value that should be returned for values that could not be calculated.always_return::Bool
: returns a vector withfill_with
equal to the initial data length if the window is longer than the length of the input data.