Skip to content
13

Variance from covariance

Statistics.var Method
julia
Statistics.var(ce::AbstractCovarianceEstimator, X::MatNum; dims::Int = 1, kwargs...)

Compute the variance vector from the diagonal of the covariance matrix.

This method extracts the diagonal of the covariance matrix returned by Statistics.cov(ce, X; dims = dims, kwargs...) and reshapes it into a row or column vector depending on dims.

Arguments

  • ce: Covariance estimator.

  • X: Data matrix of asset returns (observations × assets).

  • dims: Dimension along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to the covariance estimator.

Returns

  • var::Matrix{<:Number}: Variance vector, shaped as (1, N) if dims == 1 or (N, 1) if dims == 2.

Related

source
Statistics.std Method
julia
Statistics.std(ce::AbstractCovarianceEstimator, X::MatNum; dims::Int = 1, kwargs...)

Compute the standard deviation vector from the diagonal of the covariance matrix.

This method extracts the diagonal of the covariance matrix returned by Statistics.cov(ce, X; dims = dims, kwargs...), takes the element-wise square root, and reshapes it into a row or column vector depending on dims.

Arguments

  • ce: Covariance estimator.

  • X: Data matrix of asset returns (observations × assets).

  • dims: Dimension along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to the covariance estimator.

Returns

  • sd::Matrix{<:Number}: Standard deviation vector, shaped as (1, N) if dims == 1 or (N, 1) if dims == 2.

Related

source