# EWMA

## Description

Practitioners may want to consider the relevance of more recent events relative to observations further in the past. The exponentially-weighted moving average (EWMA) model calculates covariances by placing more emphasis on recent observations via a decay factor,$$\lambda$$.

{% hint style="info" %}
For a detailed description on the decay factor and its relationship to half-life, please see <https://wpahelp.windhamlabs.com/expected-risk/exponential-risk#half-life>
{% endhint %}

## Syntax

The following describes the function signature for use in Microsoft Excel's formula bar.

```excel-formula
=EWMA(type, assetReturns, lambda, dataPeriodicity)
```

### Input(s)

| Argument            | Description                                                                                                                                                                                    |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **type**            | <p>Required. Enumeration string to specify calculation type:<br>   "risk", "sigma", or "stdev"<br>   "correlation", "corr", or "rho", <br>   "covariance", "covar", or "cov"</p>               |
| **assetReturns**    | Required. Time series or matrix of asset returns.                                                                                                                                              |
| **lambda**          | Required. Decay factor, scalar.                                                                                                                                                                |
| **dataPeriodicity** | <p>Optional. Periodicity of the data, used for annualization. If you do not enter the argument, it defaults to 1. <br><em>e.g. Daily = 255, Monthly = 12,  Yearly = 1, Quarterly = 4.</em></p> |

### Output(s)

Depending on the specified output *type*, the function will return the respective vector of risk estimates (annualized standard deviations), correlation matrix, or a covariance matrix.

## Example

![](https://258561627-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK66-MGuoULhqCDXLwy%2F-ML9A0ubdYUndPL82Yl6%2F-ML9BP0uZzvVdMJdbhNJ%2Fewma.gif?alt=media\&token=9eded642-d0ee-4c49-ab0a-ce0a7cf82f6b)

{% file src="<https://258561627-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK66-MGuoULhqCDXLwy%2F-MQFn0uluutUG7MS23bT%2F-ML9Brk9J_GZRVZ1mTsw%2FEWMA.xlsx?alt=media&token=f7c4b9ea-f2aa-4a53-a578-0d1d568a1f47>" %}
Example Workbook: EWMA
{% endfile %}
