MATLAB Answers

How do I calculate the annual average log returns and stansard deviation from a series of monthly log returns?

8 ビュー (過去 30 日間)
Lars-Martin Fossgard
Lars-Martin Fossgard 2019 年 10 月 2 日
編集済み: Akshit Agarwal 2019 年 10 月 7 日
I would like to extract annual avrage log returns and standard deviation from a dataset containing dates and monthly log returns. Do you know how to solve this? I have calculated the monthly log returns, how do I calculate the annual avrage and standard deviation. I guess I need some sort of loop function, taken in consideration the formula for log return.

回答 (1 件)

Akshit Agarwal
Akshit Agarwal 2019 年 10 月 7 日
編集済み: Akshit Agarwal 2019 年 10 月 7 日
Hi Lars-Martin,
MATLAB supports Vectorizing of your code, so you don't necessarily need to use any looping function.
You can import your data using load() if its a .mat file or readtable() for other files such as spreadsheets, text files etc.
And then accordingly you can pass the data to the built in functions such as standard deviation, exponential, average (mean), logarithm etc. that you might need for your problem statement.
You can search the documentation for any other functions if required.

Community Treasure Hunt

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

Start Hunting!

Translated by