Simple expected returns
The most basic moment is the simple expected return. These types and functions implement it.
PortfolioOptimisers.SimpleExpectedReturns Type
struct SimpleExpectedReturns{T1, T2} <: AbstractExpectedReturnsEstimator
w::T1
idx::T2
endA 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. It supports both unweighted and weighted mean estimation by storing an optional weights vector.
Fields
w: Optional weights for each observation. Ifnothing, the unweighted mean is computed.idx: Optional indices of the observations to use for estimation. Ifnothing, all observations are used.
Constructor
SimpleExpectedReturns(; w::Option{<:StatsBase.AbstractWeights} = nothing,
idx::Option{<:VecInt} = nothing)Keyword arguments correspond to the fields above.
Validation
- If `w` is not `nothing`, `!isempty(w)`.
- If `idx` is not `nothing`, `!isempty(idx)` and all indices are positive integers.Examples
julia> SimpleExpectedReturns()
SimpleExpectedReturns
w ┼ nothing
idx ┴ nothing
julia> SimpleExpectedReturns(; w = StatsBase.Weights([0.5, 0.5]))
SimpleExpectedReturns
w ┼ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.5, 0.5]
idx ┴ nothingRelated
sourcePortfolioOptimisers.factory Method
factory(me::SimpleExpectedReturns, w::StatsBase.AbstractWeights)Create a new SimpleExpectedReturns estimator with observation weights w.
This function constructs a new SimpleExpectedReturns object, replacing the weights stored in the input estimator with the provided weights.
Arguments
me: Expected returns estimator.w: Observation weights vector.
Returns
me::SimpleExpectedReturns: New estimator with observation weightsw.
Related
sourceStatistics.mean Method
Statistics.mean(me::SimpleExpectedReturns, X::MatNum; dims::Int = 1, kwargs...)Compute the mean of asset returns using a SimpleExpectedReturns estimator.
This method computes the expected returns as the sample mean of the input data X, optionally using observation weights stored in the estimator. If no weights are provided, the unweighted mean is computed.
Arguments
me: Expected returns estimator.X: Data matrix.dims: Dimensions along which to perform the computation.kwargs...: Additional keyword arguments passed toStatistics.mean.
Returns
mu::VecNum: The expected returns vector.
Examples
julia> X = [0.01 0.02; 0.03 0.04];
julia> ser = SimpleExpectedReturns()
SimpleExpectedReturns
w ┼ nothing
idx ┴ 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]
idx ┴ nothing
julia> mean(serw, X)
1×2 Matrix{Float64}:
0.026 0.036Related
source