<< mef Financial module nelson_siegel >>

Financial module >> Financial module > movav

movav

Compute and draw the moving average of a given time series

SYNOPSIS

M=movav(x [,m1 [,m2 [,...]]]);

Description

On the data "x" the function compute the moving averages of length m1, m2, and so on. Finally it draws the data "x" and all the moving averages.

Parameters

x
data the moving averages are computed on
m1, m2, ...
lengths of the moving averages

Output

M
matrix containing, in any column, the moving average of the historical data (each column has a different length)

Example

First we generate 1000 log-normally distributed daily asset prices with 0.1/250 mean and 0.2/sqrt(250) variance. The first price of the asset is 25 euros.

-->M=grand(1000,1,'nor',0.1/250,0.2/sqrt(250));

-->price=exp(cumsum(M,1))*25;

Now we can use the function for computing the moving averages at 10 days and 30 days

-->M=movav(price,10,30);

The graph shows the historical data and both moving averages.

Authors

Francesco Menoncin - Brescia University - 2010


<< mef Financial module nelson_siegel >>