Hi,

I have a distribution over time in months but I wanted to divide and represent it with 3 slopes. I used the segmented package for piecewise regression but the graph obtained is not exactly what I was aiming for. The drop after slope 2 I wanted to see is somehow in linear continuity with slope 3. I need help adjusting my graph in picture 1 to look more like picture 2, as the whole purpose is to estimate the drop between slope 2 and 3.

Code used:

library(segmented)

#making a linear model (df=name of dataframe)

#x axis = timemonth, avg_in = y axis

df_lin <- lm(avg_in~timemonth, data=df)

summary(df_lin)

#making a segmented model (psi breakpoint) #interested breakpoints = 25, 115, 132

df_seg <- segmented(df_lin, seg.Z = ~ timemonth, psi = 25, 115, 132)

summary(df_seg)

plot(df_seg)

# get the breakpoints

df_seg$psi

**Result**

Initial Est. St.Err

psi1.timemonth 25 23.72201 2.306182

**Question: Why is it only showing results for the 1 breakpoint?**

# get the slopes

slope(df_seg)

**Results** Est. St.Err. t value

slope1 2.9987e-05 3.9974e-05 0.75015

slope2 -2.2570e-04 3.7542e-06 -60.11900

slope3 -7.9043e-05 6.4128e-05 -1.23260

CI(95%).l CI(95%).u

slope1 -4.9054e-05 1.0903e-04

slope2 -2.3313e-04 -2.1828e-04

slope3 -2.0584e-04 4.7757e-05

Question: However when I check for slopes I get results for all 3, then why only one breakpoint?

Any help will be appreciated to get my graph right? and if someone can also help with other secondary questions I shall be forever grateful.