Compute geometric mean of returns of a data sample when some returns are negative

6 次查看(过去 30 天)
Hi community,
I have a (probably a trivial) question in regards to computing the mean of log returns of 3 assets.
The dataset (real_ret) I have contains 92 returns whereas some are negative.
When I try to compute the following:
geometric_ret = exp(mean(log(real_ret))); (we should use this according to our finance professor, and it works when the dataset only contains positive values).
I get an answer that is 0.0048 + 0.0172i, 0.0173 + 0.0488i, etc..
I realize that the "+ 0.0172i" part comes from the fact that the dataset contains negative values, but how do you work around this issue to get the correct geometric mean of returns?
The dataset is a 92x4 double.
Thank you.
  1 个评论
Bjorn Gustavsson
Bjorn Gustavsson 2021-11-11
The only way this makes sense to me is if your real_ret is the change of value (possibly relative change) such that all the values of the commodities/stocks/whatevers remain positive - if this is the case then you'd have to add the initial values to each and calculate the geometric mean of that, and compare to the geometric mean of the initial values.

请先登录,再进行评论。

回答(1 个)

Shivam Lahoti
Shivam Lahoti 2024-2-15
Hi Jesper,
The appearance of complex numbers when computing the geometric mean of log returns suggests that the logarithm function is being applied to negative numbers, which is mathematically invalid for real numbers. Log returns should be calculated from positive asset prices, and they can be negative if prices decrease, but this should not cause complex numbers in the calculation.
To compute the correct geometric mean of log returns, take the following steps:
  1. Verify Log Returns: Ensure that the log returns are calculated correctly from positive price data as log(P_t / P_{t-1}).
  2. Use Arithmetic Mean for Log Returns: Calculate the arithmetic mean of the log returns directly. This is the correct approach when dealing with log returns, as they can be negative but still represent valid percentage changes over time.
  3. Exponentiate the Mean: Apply the exponential function to the arithmetic mean of the log returns to obtain the geometric mean return.
arithmetic_mean_log_returns = mean(real_ret);
geometric_ret = exp(arithmetic_mean_log_returns);
This will result in a real-valued geometric mean return for each asset. If you still encounter complex numbers, there may be errors in your dataset. Double-check the data to ensure all prices are positive and that the log returns are calculated correctly. Correct any data issues before attempting to recalculate the geometric mean return.
I hope it helps,
Shivam.

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by