两阶段线性回归模型在Python -地球科学堆栈交换江南电子竞技平台江南体育网页版 最近30从www.hoelymoley.com 2023 - 07 - 10 - t09:03:11z //www.hoelymoley.com/feeds/question/24455 https://creativecommons.org/licenses/by-sa/4.0/rdf //www.hoelymoley.com/q/24455 3 两阶段在Python中线性回归模型 Bidyut比Goswami炮轰道: //www.hoelymoley.com/users/20531 2022 - 10 - 25 - t09:28:13z 2022 - 10 - 26 - t06:32:01z < p >这是我的第一篇文章。I am trying my best to follow all the "how to ask a question" guidelines and hopefully my question will be clear.

I am trying to find the change of slope in a time series. I used the ruptures (for 2 break points using model = rpt.Dynp(model="l1") and this is what I got (please see the attached image). enter image description here

I am not happy with the break point location. Based on my visual inspection of the data, I feel the break-point is earlier than what I am getting. I wanted to do a "Two-phase linear regression" to check my results. I found that there is a function available in Matlab. I am wondering if there is any python package available to do the same thing what this Matlab function does, because I know nothing about Matlab.

Thank you in advance for your inputs.

[If anyone is wondering what happens if I try to find 3 or 4 break-points in my data, instead of looking for 2 break-points, then please see the images below. I am still not happy with the first change point location.] enter image description here enter image description here

//www.hoelymoley.com/questions/24455/-/24459 # 24459 1 回答大卫Hammen两阶段在Python中线性回归模型 大卫Hammen //www.hoelymoley.com/users/239 2022 - 10 - 26 - t06:19:38z 2022 - 10 - 26 - t06:32:01z

I wanted to do a "Two-phase linear regression" to check my results.

You aren't doing that. By specifying model="l1", you are asking the package to use a piecewise constant model (rather than a linear regression) for each segment. This models each segment as the mean of all the elements in that segment. The error is calculated as the sum of the absolute values of the difference between each element and the mean (the $L^1$ norm). Apparently asking for two breakpoints means one internal breakpoint, or two segments that collectively span the dataset.

That is not a good model of your dataset, and it is not a linear regression.

Baidu
map