In R I have produced a piecewise linear regression model and I have the outputs for the model, however, I need help constructing the models formula and I can't find online a formula to calculate the model with two breakpoints.
Please let me know if someone is able to help, I will include my figures below:
psi1.x 34.125 (breakpoint 1) psi2.x 63.690 (breakpoint 2)
(Intercept) 39.71818 x 0.23644 U1.x -0.33708 U2.x 0.42017
Thank you
I am expecting three formulas for the different intervals of my data that looks like y = B0 + B1x + e(t).
The code is as follows:
# Load necessary packages
library(segmented)
library(lmtest)
#create data
Date <- c(1:93)
Percentage <- c("38.2", "39.2", "40.4", "40.7", "41.5", "41.9", "42", "41.4", "41.9", "42.5", "42.5", "42.6", "42.4", "42.4", "43.4", "43.4", "44", "44.1", "45.2", "44.6", "45", "45.3", "45.2", "44.8", "46.2", "46.4", "46.4", "46.1", "46.4", "46.4", "46.7", "46.7", "47", "47.5", "46.4", "46.7", "46.6", "47.6", "47.8", "47.5", "47.9", "47.7", "47.7", "47", "46.8", "47.1", "46.8", "45.6", "45.2", "45.7", "46.4", "46.7", "45.5", "45.5", "45.5", "45.9", "45.8", "46.4", "46.7", "46.4", "43.6", "43.4", "44.2", "44.2", "44.9", "45.8", "45.5", "46.3", "45.9", "45.6", "46.6", "46.9", "47.9", "48.2", "49.5", "49", "49.2", "49.8", "50.5", "50.7", "50.7", "51.2", "51.5", "51.7", "52.6", "53.2", "54.1", "53.5", "52.3", "51.8", "52.2", "52.3", "52.7")
Percentage <- as.numeric(Percentage
disabilityemployment <- data.frame(Date, Percentage)
View(disabilityemployment)
y <- disabilityemployment$Percentage
x <- disabilityemployment$Date
# Fit initial piecewise linear regression model
seg.model <- segmented(lm(y ~ x, data = disabilityemployment), seg.Z = ~x, npsi = 2)
summary(seg.model)