I have used mkspline to make the variables for a piecewise regression
Then fit a piecewise regression with an interaction by a categorical variable with 3 levels:
This works just fine (see attached), but when I plot the raw means by group (see attached) I see that two of the groups appear to have a quadratic trend after the spline while only one is truly linear. Is there a way to incorporate these quadratic trends after the spline for these two groups to at least test if the quadratic is actually significant?


Code:
mkspline preH 3 postH = time generate jump = 1 replace jump = 0 if time < 3
Code:
mixed hrelsat c.preH#ibn.H_Group i.jump#ibn.H_Group c.postH#ibn.H_Group || CSID: preH jump postH
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double CSID byte time double(hrelsat wrelsat H_Group W_Group H5_Exposure W5_Exposure) byte(preH postH) float jump 10056 0 50 46 3 3 1 2 1 0 0 10056 1 50 46 3 3 1 2 2 0 0 10056 2 46 50 3 3 1 2 3 0 1 10056 3 50 43 3 3 1 2 3 2 1 10056 4 48 27 3 3 1 2 3 3 1 10056 5 50 41 3 3 1 2 3 4 1 10060 0 47 46 2 2 4 . 1 0 0 10060 1 35 15 2 2 4 . 2 0 0 10060 2 37 46 2 2 4 . 3 0 1 10060 3 . . 2 2 4 . 3 2 1 10060 4 . . 2 2 4 . 3 3 1 10060 5 . . 2 2 4 . 3 4 1 10073 0 48 44 3 3 5 5 1 0 0 10073 1 50 52 3 3 5 5 2 0 0 10073 2 49 52 3 3 5 5 3 0 1 10073 3 47 52 3 3 5 5 3 2 1 10073 4 51 52 3 3 5 5 3 3 1 10073 5 48 52 3 3 5 5 3 4 1 10080 0 51 52 3 3 7 5 1 0 0 10080 1 51 49 3 3 7 5 2 0 0 10080 2 48 50 3 3 7 5 3 0 1 10080 3 46 46 3 3 7 5 3 2 1 10080 4 45 48 3 3 7 5 3 3 1 10080 5 46 50 3 3 7 5 3 4 1 10081 0 17 20 1 1 . . 1 0 0 10081 1 . . 1 1 . . 2 0 0 10081 2 . . 1 1 . . 3 0 1 10081 3 50 41 1 1 . . 3 2 1 10081 4 . . 1 1 . . 3 3 1 10081 5 . . 1 1 . . 3 4 1 10089 0 45 30 3 2 3 6 1 0 0 10089 1 46 32 3 2 3 6 2 0 0
Comment