JeffreySarnoff / RollingFunctions.jl

Roll a window over data; apply a function over the window.
MIT License
114 stars 6 forks source link

rolling regression #18

Open waynelapierre opened 3 years ago

waynelapierre commented 3 years ago

Could you add a rolling regression function that can return the regression coefficients and R squared value? With this function, your package would be super useful for time series analysis.

JeffreySarnoff commented 3 years ago

Seems appropriate -- can you tell me how to write or where to see excellent and easily intuited examples of rolling regression functions that can return the regression coefficients and R squared value?

waynelapierre commented 3 years ago

https://stackoverflow.com/questions/59361325/how-to-get-a-rolling-window-regression-in-julia

https://github.com/jjf234/roll/blob/master/src/roll.cpp

JeffreySarnoff commented 3 years ago

what does this roll over, is it a single stream of floating point values or are there e.g. a stream of xs and a synced stream of ys or is it some third way?

waynelapierre commented 3 years ago

yes, the rolling function should be able to regress one stream of ys on one stream of xs or multiple streams of xs (x1, x2, x3, etc.).

JeffreySarnoff commented 3 years ago

(broad question, useful for me to hear from you for design purposes) what does regressing one stream of ys on one or more streams xs_i provide that is helpful, what is the manner of that help?

waynelapierre commented 3 years ago

in finance, it is common to use rolling regressions to estimate various measures of volatilities.

JeffreySarnoff commented 3 years ago

Thank you. The package was written as a flexible and facile datastream engager, with special emphasis on preserving the information available in trailing or in leading datapoints as the applicable window becomes foreshortened. The current code has no knowledge about nor understanding of concomitant data streams. This would be a vaild reason to revisit the software architecture and revise the way it approaches and is approached. I will attend this and the exemplars you have linked well enough to see a way forward -- my time for this now is limited. I do respect the request; and will use this issue as a notepad, adding when there is something to be added.

There is a new branch #multiflows for the initial whiteboarding. If this effort is successful, that branch will fall away for a next approach to implementation.

JeffreySarnoff commented 3 years ago

@waynelapierre I have reviewed what needs to be done, and it requires changing the package design so it will operate as expected when given multiple datastreams which share some influence on the way information is rolled up. That is time-consuming, but not conceptually difficult. This package was written years ago, before I thought much about moderating allocations or enhancing performance. The first update to the code base would be revisiting that .. and I do not have the availability for that now. As I cannot give you a timeline, please do not delay work of your own until this package is reworked.

p-casgrain commented 2 years ago

@waynelapierre I believe that the OnlineStats.jl may have what you are looking for and more. In particular, OnlineStats.LinReg and OnlineStats.LinRegBuilder may provide the functionality are looking for.