Stats workshop follow-up: Piecewise regression resources
Hi all, Today in the later half of the statistics workshop, we discussed piecewise regression as a possible solution to a question brought up to discussion. To provide some more help and resources for how to run a piecewise regression in practice, see below. What is piecewise regression? For some context for those of you who do not know what piecewise regression is: it has many names - piecewise regression, segmented analysis, changepoint analysis, breakpoint analysis, etc. Essentially, it is a regression analysis where the slope changes at certain points (=breakpoints) of the x-axis. A research question can be focused on estimating the slopes at different segments, discovering whether breakpoint(s) exist, or both. See the figure below for a (made-up) example of how a slope can change in segments determined by 2 breakpoints. Analysis can be segmented, when the x-axis has continuity and the segments connect to one another (like in the figure), or stegmented, where the segments do not connect, but rather there is a jump to a different starting point for each segment. [cid:image003.png@01DC540A.E6E49B20] Resources You can find a template/tutorial for how to run piecewise regression in R, from GitHub following the link below. Some of you may have received different versions of this code previously, and it has evolved over time, and may keep evolving in the future. You can copy or download the script to run it in your own computer. https://github.com/MaaritIMaenpaa/Stats101/blob/main/example_code/Piecewise_... For more information, take a look at the tutorials for specific packages below. Which R package you need will depend on your focus and your data. Package segmented: An overview of how to do piecewise regression: https://www.youtube.com/watch?v=NRaFJG1jWoQ Minimum words, but nice code to show what a segmented model can do: https://rpubs.com/MarkusLoew/12164 A tutorial for strucchange (alternative package) can be found here: https://kevin-kotze.gitlab.io/tsm/ts-2-tut/ A tutorial for yet another package, mcp: https://lindeloev.github.io/mcp/ Good luck for your analyses, and happy coding! 😊 Best regards, Maarit Maarit Mäenpää Statistician Dept. of Agroecology Aarhus University Blichers Allé 20, Postboks 50 DK-8830 Tjele Web: agro.au.dk Phone: 51 335 104 E-mail: m.maenpaa@agro.au.dk<mailto:m.maenpaa@agro.au.dk> AGRO employee? Book a statistics consultation: https://tinyurl.com/4tvesj3u [AU Logo] ”Please note that this email may contain personal data. You must ensure that this data cannot be accessed by anyone else without good reason, and that it is deleted immediately when it is no longer required in relation to the purpose for which it was sent”.
participants (1)
-
Information about statistics events at AGRO