# ewstats

Expected return and covariance from return time series

## Syntax

## Description

`[`

computes estimated expected returns (`ExpReturn`

,`ExpCovariance`

,`NumEffObs`

] = ewstats(`RetSeries`

)`ExpReturn`

), estimated
covariance matrix (`ExpCovariance`

), and the number of
effective observations (`NumEffObs`

). These outputs are
maximum likelihood estimates which are biased.

`[`

adds optional input arguments for `ExpReturn`

,`ExpCovariance`

,`NumEffObs`

] = ewstats(___,`DecayFactor`

,`WindowLength`

)`DecayFactor`

and
`WindowLength`

.

## Examples

## Input Arguments

## Output Arguments

## Algorithms

For a return series
*r*(1),…,*r*(*n*), where
(*n*) is the most recent observation, and *w*
is the decay factor, the expected returns (`ExpReturn`

) are
calculated by

$$E(r)=\frac{(r(n)+wr(n-1)+{w}^{2}r(n-2)+\mathrm{...}+{w}^{n-1}r(1))}{NumEffObs}$$

where the number of effective observations `NumEffObs`

is
defined as

$$NumEffObs=1+w+{w}^{2}+\mathrm{...}+{w}^{n-1}=\frac{1-{w}^{n}}{1-w}$$

*E*(*r*) is the weighed average of
*r*(*n*),…,*r*(`1`

).
The unnormalized weights are *w*,
*w*^{2}, …,
*w*^{(n-1)}. The unnormalized weights do
not sum up to `1`

, so `NumEffObs`

rescales the
unnormalized weights. After rescaling, the normalized weights (which sum up to
`1`

) are used for averaging. When *w* =
`1`

, then `NumEffObs`

= *n*,
which is the number of observations. When *w* <
`1`

, `NumEffObs`

is still interpreted as the sample
size, but it is less than *n* due to the down-weight on the
observations of the remote past.

**Note**

There is no relationship between `ewstats`

function and the
RiskMetrics® approach for determining the expected return and covariance from a
return time series.

## Version History

**Introduced before R2006a**