[R-sig-ME] Piecewise linear regression with lmer
João Veríssimo
j|@ver|@@|mo @end|ng |rom gm@||@com
Fri Mar 3 19:41:15 CET 2023
Hi Christopher,
I think you'd do this in lmer in the same way as for any
(non-mixed-effects) regression, with the only caveat being that you may
want/need to include the relevant predictors as random slopes.
You'd start by determining a breakpoint, centering your variable of
interest around it, and creating an indicator variable:
df$Shitfed.V1 <- df$V1 - breakpoint # 'Shift'
variable (i.e., center around the breakpoint)
df$post.breakpoint <- as.factor(df$Shitfed.V1 > 0) # Create indicator
variable (as factor)
Then the following lmer model formula would yield estimates for: (a) the
'left' slope, i.e., for V1 smaller than the breakpoint; and (b) the
difference between slopes:
DV ~ 1 + Shitfed.V1 + Shitfed.V1:post.breakpoint + (1 + Shitfed.V1 +
Shitfed.V1:post.breakpoint | RandomFactor)
Alternatively, this lmer formula would yield estimates for: (a) the
'left' slope, i.e., for V1 smaller than the breakpoint; (b) the 'right'
slope, i.e., for V1 larger than the breakpoint:
DV ~ 1 + Shitfed.V1:post.breakpoint + (1 + Shitfed.V1:post.breakpoint |
RandomFactor)
João
On 01/03/2023 15:44, Cortina, Christopher Anibal wrote:
> Hello!
>
> I am working on a project and am looking for a way to run piecewise linear regression with lmer that will give me interpretable parameters for each piece. What is the best way to do this?
>
> Thank you!
>
> Christopher Cortina
> MS Biostatistics c/o 2023
> Gillings School of Global Public Health
> The University of North Carolina at Chapel Hill
> Pronouns: he/him/his
> cortinac using live.unc.edu
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
More information about the R-sig-mixed-models
mailing list