Simple expected returns
The most basic moment is the simple expected return. These types and functions implement it.
PortfolioOptimisers.SimpleExpectedReturns Type
struct SimpleExpectedReturns{__T_w} <: AbstractExpectedReturnsEstimatorA simple expected returns estimator for PortfolioOptimisers.jl, representing the sample mean with optional observation weights.
SimpleExpectedReturns is the standard estimator for computing expected returns as the possibly weighted mean of asset returns.
Fields
w: Optional observation weights vectorobservations × 1, or a concrete subtype ofDynamicAbstractWeights. Ifnothing, the computation is unweighted.
Constructors
SimpleExpectedReturns(;
w::Option{<:ObsWeights} = nothing
) -> SimpleExpectedReturnsKeywords correspond to the struct's fields.
Validation
- If
wis notnothing,!isempty(w).
Examples
julia> SimpleExpectedReturns()
SimpleExpectedReturns
w ┴ nothing
julia> SimpleExpectedReturns(; w = StatsBase.Weights([0.5, 0.5]))
SimpleExpectedReturns
w ┴ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.5, 0.5]Related
sourceStatistics.mean Method
Statistics.mean(
me::SimpleExpectedReturns,
X::MatNum;
dims::Int = 1,
kwargs...
) -> ArrNumCompute the mean of asset returns using a SimpleExpectedReturns estimator.
This method computes the expected returns as the sample mean of the input data X according to ce.
Mathematical definition
Unweighted:
Where:
: vector of estimated expected returns. : Return of asset at time . : Number of observations.
Weighted:
Where:
: vector of estimated expected returns. : Return of asset at time . : Number of observations. : Observation weight at time .
Arguments
me: Expected returns estimator.X: Data matrixobservations × featuresif thedimskeyword does not exist ordims = 1,features × observationswhendims = 2.dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed toStatistics.mean.
Returns
mu::ArrNum: Expected returns vectorfeatures x 1if thedimskeyword does not exist ordims = 2,1 x featuresifdims = 1.
Examples
julia> X = [0.01 0.02; 0.03 0.04];
julia> ser = SimpleExpectedReturns()
SimpleExpectedReturns
w ┴ nothing
julia> mean(ser, X)
1×2 Matrix{Float64}:
0.02 0.03
julia> serw = SimpleExpectedReturns(; w = StatsBase.Weights([0.2, 0.8]))
SimpleExpectedReturns
w ┴ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.2, 0.8]
julia> mean(serw, X)
1×2 Matrix{Float64}:
0.026 0.036Related
source