Hello dear StackOverflow Community,
First of all, I want to thank everybody who contributes to this Forum and thus directly and indirectly helps all those in the world with less developed coding skills.
Now to my question. I have a series of volatilities and each of the last 12 volatilities are used in an exponential weighted moving average to forecast the volatility of the period. See the formula below in the image.
https://i.stack.imgur.com/Z7dn3.png
Now I need to get the weight value which should be done by using a Newton Raphson Algorithm to minimize the sum of the squared errors for different weights. My question is now how to elegantly translate that into Python. I've already watched tutorials on how to do the Newton method but most of them relate to simpler functions and I can't find anything about Time Series.
My idea would be to start a loop at a certain weight and calculate the sum of squared errors for the series and that weight and then lower that weight in a loop every time the result of those summed squared errors is smaller in 0.1 increments and then if it starts rising again to go up with the weight by 0.01 until the error result rises again. However, this seems to be a rather complicated approach and I would be very delighted if somebody could tell me if there is another more simplistic and maybe build-in way to deal with this problem since I'm very inexperienced in the work with Python and Time Series.
So I don't particularly look for a coding example but more for a guideline on where and how to look for a solution for my problem instead of making it too difficult for myself.
Thanks in advance
Nick