question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add piecewise regression example

See original GitHub issue

We can define

def truncate(x, l):
    x = (x - l) * (x >= l)
    return x

And then simply do

formula = "response ~ x + truncate(x, 10) + truncate(x, 20)"

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
tomicaprettocommented, Jan 22, 2022

I like when people get involved in the issues and propose new ideas. I really appreciate your comments. So please feel free to share when you want to propose something.

To be a little clearer, I’m not saying that we should only have the example using truncated(). What I’m saying is that we could have both, and explain the connection between them 😉

1reaction
hadjipanteliscommented, Jan 22, 2022

Fair points. I appreciate that my proposition might be a tad bullish regarding people’s familiarity with splines use.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Perform Piecewise Regression in R (Step-by-Step)
This tutorial explains how to perform piecewise regression in R, including a step-by-step example.
Read more >
8.8 - Piecewise Linear Regression Models | STAT 501
Let's start with an example that demonstrates the need for using a piecewise approach to our linear regression model. Consider the following plot...
Read more >
R for Ecologists: Putting Together a Piecewise Regression
To use this method, you first fit a generic linear model. You then use the segmented( ) function to fit the piecewise regression....
Read more >
2 Piecewise Regression and Splines - Bookdown
2.1 Introduction. An alternative to fit all data points with a single polynomial curve, is to fit segments to different parts of the...
Read more >
Piecewise Linear Regression Model. What Is It and When Can ...
The problem of polynomial regression is that you lose the interpretability of the model when adding the polynomial terms (quadratic, cubic, etc) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found