Empirical Prior
PortfolioOptimisers.EmpiricalPrior Type
struct EmpiricalPrior{__T_ce, __T_me, __T_horizon} <: AbstractLowOrderPriorEstimator_AEmpirical prior estimator for asset returns.
EmpiricalPrior is a low order prior estimator that computes the mean and covariance of asset returns using empirical (sample-based) statistics. It supports custom expected returns and covariance estimators, as well as an optional investment horizon for log-normalisation and scaling.
Fields
ce: Covariance estimator.me: Expected returns estimator.horizon: Optional investment horizon for log-normalising returns. Ifnothing, returns are not adjusted.
Constructors
EmpiricalPrior(;
ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance(),
me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
horizon::Option{<:Number} = nothing
) -> EmpiricalPriorKeywords correspond to the struct's fields.
Validation
- If
horizonis notnothing,horizon > 0.
Examples
julia> EmpiricalPrior()
EmpiricalPrior
ce ┼ PortfolioOptimisersCovariance
│ ce ┼ Covariance
│ │ me ┼ SimpleExpectedReturns
│ │ │ w ┴ nothing
│ │ ce ┼ GeneralCovariance
│ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ w ┴ nothing
│ │ alg ┴ Full()
│ mp ┼ MatrixProcessing
│ │ pdm ┼ Posdef
│ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ │ │ kwargs ┴ @NamedTuple{}: NamedTuple()
│ │ dn ┼ nothing
│ │ dt ┼ nothing
│ │ alg ┼ nothing
│ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)
me ┼ SimpleExpectedReturns
│ w ┴ nothing
horizon ┴ nothingRelated
PortfolioOptimisers.factory Method
factory(
pe::EmpiricalPrior,
w::Union{DynamicAbstractWeights, AbstractWeights}
) -> Union{EmpiricalPrior{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, Nothing}, EmpiricalPrior{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, <:Number}}Return a new EmpiricalPrior estimator with observation weights w applied to the underlying covariance and expected returns estimators.
Related
sourcePortfolioOptimisers.prior Method
prior(pe::EmpiricalPrior{<:Any, <:Any, Nothing}, X::MatNum, args...; dims::Int = 1,
kwargs...)Compute empirical prior moments for asset returns (no horizon adjustment).
prior estimates the mean and covariance of asset returns using the specified empirical prior estimator, without log-normalisation or scaling for investment horizon. The mean and covariance are computed using the estimators stored in pe, and returned in a LowOrderPrior result.
Mathematical definition
The empirical prior directly estimates first and second moments from the sample:
Where:
: sample mean vector. : sample covariance matrix. : vector of asset returns at time . : Number of observations.
Arguments
pe: Empirical prior estimator.X: Asset returns matrix (observations × assets).args...: Additional positional arguments (ignored).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to mean and covariance estimators.
Returns
pr::LowOrderPrior: Result object containing asset returns, mean vector, and covariance matrix.
Validation
dims in (1, 2).
Related
sourcePortfolioOptimisers.prior Method
prior(pe::EmpiricalPrior{<:Any, <:Any, <:Number}, X::MatNum, args...; dims::Int = 1,
kwargs...)Compute empirical prior moments for asset returns with investment horizon adjustment.
prior estimates the mean and covariance of asset returns using the specified empirical prior estimator, applying log-normalisation and scaling for the investment horizon. The asset returns are log-transformed, moments are computed using the estimators stored in pe, and then rescaled according to the investment horizon. The final mean and covariance are transformed back to arithmetic returns and returned in a LowOrderPrior result.
Mathematical definition
Log-returns are computed and scaled by the investment horizon
Where:
, : Horizon-scaled log-return mean and covariance. : Investment horizon. , : Sample mean and covariance of log-returns . : Arithmetic mean return for asset . : Arithmetic covariance between assets and .
Arguments
pe: Empirical prior estimator.X: Asset returns matrix (observations × assets).args...: Additional positional arguments (ignored).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to mean and covariance estimators.
Returns
pr::LowOrderPrior: Result object containing asset returns, mean vector, and covariance matrix.
Validation
dims in (1, 2).
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
pe::EmpiricalPrior,
i,
args...
) -> Union{EmpiricalPrior{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, Nothing}, EmpiricalPrior{<:CovarianceEstimator, <:AbstractExpectedReturnsEstimator, <:Number}}Return a new EmpiricalPrior estimator restricted to the assets at index i.
Related
source