Why log returns in MatLab are different from log returns in Excel?

3 ビュー (過去 30 日間)
Ekaterina Serikova
Ekaterina Serikova 2016 年 5 月 15 日
編集済み: Geoff Hayes 2016 年 5 月 15 日
Hello, I'm completely stuck with return calculation in matlab. I have three different lines of code that deliver me the same return numbers in MatLab (final is a matrix of prices):
1. pret=NaN(size(final,1), size(final,2));
pret(:,1)=final(:,1);
for i=2:size(final,1);
pret(i,2:end)=log(final(i,2:end))-log(final(i-1,2:end));
end
2. pret=NaN(size(final,1), size(final,2));
pret(:,1)=final(:,1);
for i=2:size(final,1);
pret(i,2:end)=log(final(i,2:end)./final(i-1,2:end));
end
3.[ret]=price2ret(final);
When I check the results in Excel by putting the formula like: =LOG(B2/B1), I have completely different numbers. Does anyone know why is that?
Addition: even log of the same number is a different number in MatLab and Excel, why?

採用された回答

Geoff Hayes
Geoff Hayes 2016 年 5 月 15 日
編集済み: Geoff Hayes 2016 年 5 月 15 日
Ekaterina - the MATLAB log function corresponds to the natural logarithm with base e (~2.718281828459...). The EXCEL log defaults to a base of 10.
In MATLAB, try using the log10 function instead.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by