Home Products & Services Educational Downloads Risk System Financial Ratios System

Manual and Help for Excel addin Metrixus - Metrics for Financial Market

-> Content

Previous: 2.2.12. Multiple Linear Regression

Next: 2.2.14. ARCH - GARCH - IGARCH - EGARCH - GJR (TGARCH)


2.2.13. Best Exponentially Weighting Volatility - EWV

EWV - Exponentially Weighted Volatility - its a technique for treatment of historic data (temporal series) which searches value the occurencies more recents to calculate the standard deviation (or volatileness for financial assets). This technique also is know as EWMA – Exponentially Weighted Moving Average.

When determinates teh standard deviation of a database equally weighed, all the deviations and errors (squared) from observations relating to mean has the same weight. Using exponentially weighting, the last (more recent) errors has a bigger weight which decreases as go in direction to old data, being the weight or coefficient determined by the following rule:
  • Coefficient D0 = (1 - )
  • Coefficient D0-i = () * Coefficient D0-i+1, for any i >0
where D0 its the last (most recent) observation and its the decay factor or exponential balance choosen.

The decay factor is, therefore, what determinates teh relevance degree from the last (most recent) sample data. A big factor gives a excessive weight to the observation (square error) end, softing the past movements. a factor so small it will have contrary effect, making the lasts (most recent) errors be less relevants.

The following table exemplifies the coefficients to applied to the errors observations using the decay factor of 0.94 (commom for financial assets):

CoefficientObservationError2 ObservedNew Error2
1 - = 0.060Last (D0)A0.060 *A
* 0.060 = 0.056D-1B0.056 * B
* 0.056 = 0.053D-2C0.053 * C
0.050D-3D0.050 * D
0.047D-4E0.047 * E
0.044D-5F0.044 * F
0.041D-6G0.041 * G
0.039D-7H0.039 * H
0.037D-8I0.037* I
0.034D-9J0.034 * J
0.032D-10K0.032 * K
0.030D-11L0.030 * L
0.029D-12M0.029 * M
0.027D-13N0.027 * N

The decline factor choosen also is responsible for the tolerance or precision level in results. By the decreasing data participation (square errors) most old, after a certain number of observations the applied coefficient will be so small that the errors value can be disconsidered.

Considering a declien factor , a tolerance T and a database with mean 0 have:

where k represents the position in time from the values of square error are undervalued.

In other words, the sum of undervalued coefficients its equivalent to the tolerance in the results. The table below exemplifies the relation between the amount of historic data used in calculating EWV, according to tolerance and the decay factor choosen:

decayTolerance
0.01%0.1%1%
0.84534026
0.86614631
0.88725436
0.90876644
0.921108355
0.9414911274
0.96226169113
0.97302227151
0.98456342228
0.99916687458

In example, using equal to 0.94 and a tolerance of 1%, from the observation 74 the errors values can be undervalued for calculating EWV. Using a tolerance of 0.1%, the errors values from observation 112 can be undervalued.
On this way, note that choosing the decay factor its critical in the process of exponential weighting.

For the determination of best decay fact, can be used the shrinking forecast error variance for the next step, that is,the factor is choosen for the forecast variance for next step (based in given data) bee shirinked. Here is good to remenber that must choose a tolerance for calculations of best factor according to the size of historic database, as well the size of database mus be enough big to allow forecast and analysis of thsi variance according to the tolerance.

The EWV its so used in finances for VaR (Value at Risk) calculus and volatileness of financial assets returns, being usual apply a logarithmic operator to the returns before the calculations. Yet in finances, its commom use the returns mean being equal 0, reducing some possible bias in the database.

Important: If exist any mathematic operator applied in data, the operation must reverted for anlysis!



2.2.13.1. Function MX.EWV

Access:

  • Menu - Insert | Function | Metrixus
  • - Toolbar Default | Metrixus

Description: Returns the sample standard deviation (or volatileness) and the mean of data or from the prices returns obtained by the exponetial weighting and, yet, the tolerance, according to the informed parameters. Allows to apply a logarithmic operator to the returns, useful in the analysis of financial assets.

The function return its obtained by the matrical format, being necessary, to obtain all output data, tree cells vertically selection and using of CTRL + SHIFT + RETURN after formula typing.

Call: MX.EWV (Data, Decay, Order, Returns, Null_Avg)

Argument

Type

Description

Data

range

Contiguous cells interval containing the data which will be analyzed. Cells with text or empty will be ignored. Must select more than 2 contiguous data cells.

Decay

double

Decay factor. Must be a number greater than 0 and lesser than 1. Case contrary, the function will return ERROR.

Order

boolean

Optional. Indicates if data are time positioned with older (insert 0). where the most old data shows first, or reverse (insert 1), where the most recent shows first. The default is 0.

Returns

integer

Optional. Indicates if the data represents prices. Insert 0 (default) to not modify the data, insert -1 to consider the prices return or insert 1 to consider the prices logarithmic return. In case of logarithmic return, the operation is reverted internally before the results be returned by the function.

Null Avg

boolean

Optional. Indicates if the mean used in calculations or standard deviation must be considered null (insert 1) or calculated (insert 0). The default is 0, that is, the mean its considered in calculations. This option does not influence in the informed mean, only in the standard deviation.


Important: The data must be ordered in time (older or reverse). Case exist more than one column in the cells interval, the data must be ordered inside the rows and columns. In older order, any data in the column A comes before any data in column B and data in the row 1 of column A come before data in the row 2 of column A!


Important: In case of application of logarithmics, the function reverts internally the operation before informing results!Importante: No caso da aplicação de operadores logarítmicos, a função reverte internamente a operação antes de informar os resultados!

Note 1: Results must be extracted from excel through selecting area for results, inserting formula with output area selected and pressing CTRL+SHIFT+RETURN.
Note 2: The Microsoft Excel has limitations to the size of data informed for the external functions and its sheets. We advise to not use external functions calls with big data size from Excel sheets. In generic form, Microsoft Excel does not support a data number greater than 32.767 fields. More details, consult on-line Help or Microsoft Excel Support.

Important: The option Returns equal 1 must be used to calculate the volatileness of financial assets returns in function of the atractivity of logarithmic operator for determinating statistics parameters!

The results for a data set n (or n–1 for the EWV prices return), a decay factor and where the most old data has index n is:

  • EWV Standard Deviation or Volatileness:can consider the data directly or the prices returns and apply a logarithmic operator to returns. Uses the informed order to weight the samples. If have application of logarithmic operator, this is reverted before returning results. The standard deviation is returned in the first cell.
    (Dados= Data; Retornos= Returns; Média= Mean; Média nula= Null Mean;)

  • Where:






Important: The mean value depends of Null Avg. option. If this option value is 1, the mean value will be 0! Case contrary, the mean value will be calculated in the determiantion of standard deviation.

  • Mean: mean in data or returns, applied or not a logarithmic operator and using the informed order to ponder the samples. If exists application of logarithmic operator, its reverted before the results return. The mean is returned in the second cell.


  • Where:






Important: This mean was not influenced by the null option, being calculated independently!

  • Tolerance: calculated for the amount of data n (or n-1 for prices return) and for the decay factor informed. The tolerance its returned in the third cell.

Example using prices return:

  • Data interval: A1:E30 (145 days)
  • Decay factor 0.94
  • Older order,with most old days first. The value 15.73% its the oldest data.
  • Analyze data return, using logarithmic operator
  • Use calculated mean
  • Data about interests rates from january to july 2001. The datas are next to the rate practised, but must be understood as hypothetical here. The last cells from interval are empty and are not considered in calculations (in fact, are ignored).

15.73%15.08%15.71%16.24%18.26%
15.70%14.99%15.72%16.25%18.28%
15.69%15.17%15.72%16.24%18.28%
15.70%15.17%15.73%16.25%18.28%
15.69%15.14%15.72%16.25%18.29%
15.69%15.15%15.71%16.24%18.30%
15.63%15.15%15.72%16.25%18.30%
15.61%15.15%15.71%16.61%18.30%
15.59%15.14%15.74%16.72%18.31%
15.58%15.12%15.73%16.75%18.31%
15.59%15.09%15.73%16.76%18.33%
15.28%15.09%15.75%16.77%18.43%
15.20%15.09%15.75%16.77%18.48%
15.20%15.09%15.82%16.76%18.44%
15.18%15.08%16.23%16.77%18.40%
15.15%15.07%16.23%16.76%18.37%
15.17%15.07%16.23%16.75%18.70%
15.18%15.05%16.23%16.73%18.95%
15.12%15.06%16.23%16.71%18.97%
15.09%15.06%16.23%16.67%18.94%
15.08%15.06%16.25%16.64%18.95%
15.04%15.12%16.23%16.66%18.95%
15.04%15.14%16.22%16.64%18.92%
15.02%15.18%16.21%16.67%18.96%
15.04%15.18%16.23%16.75%18.96%
15.05%15.72%16.23%16.78%
15.08%15.73%16.24%17.22%
15.10%15.72%16.25%18.26%
15.09%15.72%16.25%18.27%
15.10%15.71%16.25%18.27%

= {MX.EWV( A1:E30, 0,94, 0, 1, 0)}

Results:

0.80835%
or
0.80835%
0.12978%
or
0.80835%
0.12978%
0.01350%






The functions return its matrical and can be returned 1, 2 or 3 cell, being the first correspondent to the volatileness of returns (used the logarithmic operator and reverted teh final operation), the second correspondent to the return means (usied the logarithmic operator for the calculus and reverted for the final operation) and the third its correspondent to the tolerance.
  • 1ª cell => Returns volatileness
  • 2ª cell => Returns mean
  • 3ª cell => Data amount tolerance
The following table illustrate the effected intermediate calculations.

(0.00191)(0.00599)0.000640.000620.00109
(0.00064)0.01194-(0.00062)-
0.00064-0.000640.00062-
(0.00064)(0.00198)(0.00064)-0.00055
-0.00066(0.00064)(0.00062)0.00055
(0.00383)-0.000640.00062-
(0.00128)-(0.00064)0.02191-
(0.00128)(0.00066)0.001910.006600.00055
(0.00064)(0.00132)(0.00064)0.00179-
0.00064(0.00199)-0.000600.00109
(0.02008)-0.001270.000600.00544
(0.00525)---0.00271
--0.00443(0.00060)(0.00217)
(0.00132)(0.00066)0.025590.00060(0.00217)
(0.00198)(0.00066)-(0.00060)(0.00163)
0.00132--(0.00060)0.01780
0.00066(0.00133)-(0.00119)0.01328
(0.00396)0.00066-(0.00120)0.00105
(0.00199)--(0.00240)(0.00158)
(0.00066)-0.00123(0.00180)0.00053
(0.00266)0.00398(0.00123)0.00120-
-0.00132(0.00062)(0.00120)(0.00158)
(0.00133)0.00264(0.00062)0.001800.00211
0.00133-0.001230.00479-
0.000660.03496-0.00179
0.001990.000640.000620.02588
0.00133(0.00064)0.000620.05864
(0.00066)--0.00055
0.00066(0.00064)--
(0.00133)-(0.00062)(0.00055)

Table of logarithmic returns with 144 data.

0.000000000090.000000002930.000000000150.000000001050.00000000059
0.000000000030.000000006640.000000000630.000000008790.00000002587
0.000000000000.000000000110.000000000170.000000001190.00000002752
0.000000000040.000000000710.000000001590.000000004580.00000000979
0.000000000020.000000000030.000000001690.000000010580.00000001043
0.000000000310.000000000130.000000000210.000000001430.00000003314
0.000000000080.000000000130.000000001910.000001391650.00000003525
0.000000000090.000000000330.000000000200.000000097990.00000001256
0.000000000050.000000000620.000000002160.000000000910.00000003990
0.000000000010.000000001040.000000001040.000000001930.00000000106
0.000000007320.000000000170.000000000000.000000002060.00000046089
0.000000000730.000000000180.000000001170.000000007510.00000005696
0.000000000030.000000000190.000000007300.000000017020.00000036447
0.000000000130.000000000470.000000465520.000000002480.00000038879
0.000000000220.000000000500.000000001410.000000019260.00000029489
0.000000000000.000000000230.000000001500.000000020500.00000996657
0.000000000010.000000001020.000000001600.000000037750.00000558740
0.000000000680.000000000060.000000001700.000000040200.00000000243
0.000000000280.000000000280.000000001810.000000093870.00000036515
0.000000000110.000000000300.000000000000.000000070260.00000002771
0.000000000460.000000001360.000000007780.000000000070.00000008383
0.000000000050.000000000000.000000004740.000000051700.00000044014
0.000000000230.000000000390.000000005040.000000002240.00000003746
0.000000000000.000000000390.000000000010.000000114230.00000010093
0.000000000020.000000275870.000000002620.00000000242
0.000000000020.000000000110.000000000770.00000641411
0.000000000000.000000001030.000000000820.00003711809
0.000000000180.000000000490.000000003160.00000000674
0.000000000020.000000001170.000000003360.00000002149
0.000000000360.000000000560.000000007770.00000004623

Table containing the contribution of each return (logarithmic return minus mean, raised to square and multiplied by the respective decay coefficient ). Observe that the first days (oldest) has a participation very low for variance calculation. The sum of this table its correspondent to the variance by exponential weighting. The square root of the sum its equivalent to the standard deviation or volatileness EWV.

Comparing the standard deviation result of 0.80% as the standard deviation equally weighed for the logarithmic return of 0.733% (not showed here), perceive the exponetial weighting effect.
Topo


2.2.13.2. Best decay command

Access:

  • Menu - Metrixus | Best EWV Decay
  • - Toolbar Metrixus

Description: Determinates the best decay factor to be used in the exponetial weighting of informed data. Uses a simulation process by exhaustion which objective to shrink teh forecats variance errors (or variance of variance) to the next instance, idicating the best decay factor in historic data.
The option Minimum tolerance determinates the amount of data used for the first forecast in each simulation. Given the minimum tolerance, if the size of the database does not be enough big for a determined decay factor, this factor will not be simulated as possible best factor. In example, for a database with 200 datas and a tolerance level set as 1%, only its possible to simulate best factors lesser than 0.97.

The option Analysis of returns from asset prices allow, as in the function EWV, effect the weighting of the returns direclty from prices.

The option its only able in case of returns of prices and allow the apply of logarithmic operators on the returns.

Also in the function EWV, its possible use data in alphabetical order direct or reverse. Use the option Reverse order (most recent data appears first) to indicate that most recent data are appears first and the most old data are the alst values informed.

Important: The data must be orderd in time. Case exist more than one column in the cells interval, the data must be ordered inside the rows and columns. In the reverse order, any data in the A column comes after any data in the column B and data in the row 1 from column A come after data 2 in column A!

The option Use 0 for data mean indicates using mean equal 0 in the calculations and simulations of volatileness.

The area or interval of data must be a contiguous area with more than 40 cells. Fields with text or empty will not be considered. The data interval must be selected before calling this command.

This command generates a new file containing the results in table format.
Generatting sheet without colors allows an easy printing and represents a best run performance.

The result of the best decay analysis its a new sheet with statistics data, that is, withouct connections with the database which origins the result. In this new sheet there is the following information, where n its the historic data amount which are valid:

  • Tolerance: repeating of minimum tolerance choosen for simulations. The minimum tolerance determinates the maximum decay factor used in the simulations and determinates the amount of historic data used for the first forecast of each simulation.

  • Max. Decay: maximum decay factor used in the simulations. Considering Tmin equal the minimum tolerance and considering the minimum amount of 30 simulations, have for a total m of data (where m its equal to the total n or total n-1 for returns):



Important: Are necessary at least 30 simulations to shrink the minimum tolerance effects in the forecasts errors for the maximum decay! Are necessary 10 cells at least to do the first forecast, independently of the tolerance. Its necessary more than 40 historic data.

  • Best decay: best decay factor obtained by the shrinking the forecast error variance for the following instant, with precision of 0.005. Considering s2j the exponetial variance weighed by a decay factor, have:



Important: A new best decay factor must be calculated when occurs events which influences permanetly in the variables behavior which are origin of historic data!


Important: A same decay factor can be used for a set of time series, being each factor of each series weighed by the standard deviation of its minimum forecast error.

  • Min. SDE.: minimum standard deviation from exponetial variance forecast error weighed by the best decay factor.

    ótimo=best

Example using interests:

In this example will be used the same data from example of the function EWV.
  • Data interval: A1:E30 (145 days)
  • Tolerance 0.5%
  • Older order, with oldest days first. The value 15.73% is the most old data.
  • Analysis data returns, using logarithmic operator
  • Use Null Avg
  • Data about interests rates from january to july 2001. The datas are next to the rate practised, but must be understood as hypothetical here. The last cells from interval are empty and are not considered in calculations (in fact, are ignored).

15.73%15.08%15.71%16.24%18.26%
15.70%14.99%15.72%16.25%18.28%
15.69%15.17%15.72%16.24%18.28%
15.70%15.17%15.73%16.25%18.28%
15.69%15.14%15.72%16.25%18.29%
15.69%15.15%15.71%16.24%18.30%
15.63%15.15%15.72%16.25%18.30%
15.61%15.15%15.71%16.61%18.30%
15.59%15.14%15.74%16.72%18.31%
15.58%15.12%15.73%16.75%18.31%
15.59%15.09%15.73%16.76%18.33%
15.28%15.09%15.75%16.77%18.43%
15.20%15.09%15.75%16.77%18.48%
15.20%15.09%15.82%16.76%18.44%
15.18%15.08%16.23%16.77%18.40%
15.15%15.07%16.23%16.76%18.37%
15.17%15.07%16.23%16.75%18.70%
15.18%15.05%16.23%16.73%18.95%
15.12%15.06%16.23%16.71%18.97%
15.09%15.06%16.23%16.67%18.94%
15.08%15.06%16.25%16.64%18.95%
15.04%15.12%16.23%16.66%18.95%
15.04%15.14%16.22%16.64%18.92%
15.02%15.18%16.21%16.67%18.96%
15.04%15.18%16.23%16.75%18.96%
15.05%15.72%16.23%16.78%
15.08%15.73%16.24%17.22%
15.10%15.72%16.25%18.26%
15.09%15.72%16.25%18.27%
15.10%15.71%16.25%18.27%

Results:

Used data logarithmics returns
Older order - Oldest data first
Null mean for variance calculations
Calculatiosn options summary

Sample144
Tolerance0.5%
Max. decay0.955
Best decay0.950
Min. SDE2.785E-05

By the results, was analysed 144 logarithmic data return (145 data of prices) and using a max. decay of 0.955 in function of the tolerance of 0.5% choosen. The best decay calculated is 0.950 and it equivalent to a standard deviation of variance of forecast errors of 2.78 x 10-5.

If the choosen tolerance was from 0,1% the results (not represented here) will point for a max. decay of 0.945 (lesser by the lesser tolerance) and a best decay of 0.930.

Example using assets:

Best Weighting for assets prices calculations.
  • Data Interval B7:B209 (203 days)
  • Tolerance 0.5%
  • Older order, with oldest days first. the price 273.00 its the most old data.
  • Anlyze data return, using a logarithmic operator
  • Use the calculated mean
  • The data represents the prices of some assets negotiated in the BOVESPA and comprehend the period from october,1997, to july,1998,. This dataare next to real prices but must be considered hypothetical here.

PETR3
273.00198.25208.00189.61193.31117.9082.46
279.00187.33209.67188.27132.06108.8386.13
279.05197.27209.59185.49131.37100.0287.44
278.02210.08211.28181.67131.38102.2390.16
275.59200.30211.07178.97131.7398.0895.41
274.24202.57213.96182.06137.5188.1796.03
275.01214.19215.20186.58142.6785.8992.61
272.14213.69213.06187.00141.0380.3394.10
271.54205.71212.19191.10138.7475.1394.90
271.87198.65210.69200.00132.6679.8094.29
271.61199.86215.73200.11132.1279.0394.93
271.66200.82217.93203.32132.0770.6096.69
265.69200.94217.21207.48131.6172.8797.39
266.68209.07215.95206.00130.5477.5294.47
265.76222.46217.87205.69128.0480.9293.25
262.33226.10219.75204.11132.2285.9890.89
253.11226.94215.66208.84134.5386.1489.40
251.06220.08204.32210.74127.8980.7389.40
225.12216.43205.12207.99125.9380.0082.49
217.11201.03204.23207.99131.5679.4881.93
219.82194.90208.05208.77133.4878.1683.61
198.86188.38208.70208.89129.9075.4384.67
181.82195.55205.11206.84128.4078.5183.67
204.85196.85201.57199.00127.9078.11
232.57194.74200.29195.33127.6775.08
247.75201.88195.12194.09124.6079.29
237.86201.48190.79192.99121.8584.83
219.06197.81185.45187.55124.0090.77
221.07200.51183.95191.16123.7988.32
217.23205.11187.34195.73118.7183.11

Results:

Used data logarithmic returns
Older order - oldest data first
Mean NOT null for variance calculations
Calculations options summary.

Sample202
Tolerance0.5%
Max. Decay0.965
Best Decay0.960
Min. SDE9.611E-05

Was analyzed 202 logarithmic return data (203 prices) and used a max. decay of 0.965 by the tolerance of 0.5% asked. The best decay calculated its 0.960 and its equivalent to the forecast variance errors standard deviation of 9.611 x 10-5.
Topo


-> Content

Previous: 2.2.12. Multiple Linear Regression

Next: 2.2.14. ARCH - GARCH - IGARCH - EGARCH - GJR (TGARCH)

Home | Company information | Tools | CED | Forum | News | Links | Clients | Cases | Templates | Careers | Contact
©All rights reserved - Élin Duxus - Brazil - 2002 - 2008


Excel course, formulas, macros, sheets - Finance Mathematics, HP 12C - Options pricing and course, options Greeks analysis - VaR (Value at Risk) course - Equity, stocks, ADR and international arbitrage - Certified Professionals - Excel add-in for finance - Customized Excel add-in - System and application development, technology - C/C++, VBA, macros, models - Communication in Excel, RTD - Financial modeling - Financial consulting, corporate finance - Cash Flow Analysis - Brazilian PPP (Public-Private Partnership) - Excel Add-in Downloads - Templates - Duxus Risk System Élin Duxus Sitemap
Excel course, formulas, macros, sheets - Finance Mathematics, HP 12C - Options pricing and course, options Greeks analysis - VaR (Value at Risk) course - Equity, stocks, ADR and international arbitrage - Certified Professionals - Excel add-in for finance - Customized Excel add-in - System and application development, technology - C/C++, VBA, macros, models - ARCH, GARCH, TGARCH, ICARG - Communication in Excel, RTD - Financial modeling - Financial consulting, corporate finance - Cash Flow Analysis - Excel Add-in Downloads - Templates - Duxus Risk System - Value at Risk - VaR - ALM - Asset Liability Simulation