Hi folks,

Trying to figure out whether it is feasible/correct to run both stratified or interaction models with splines.

My understanding is that interaction & stratified won’t be the same with splines (they’re not quite – I checked the regression parameters). But it’s only the adjustrcspline package that warns against interaction models – they seem to be OK from my read of the stats threads. Unsure if missing something though...?

I ran the spline models stratified first, then interaction models, extracting something fairly logical using margins and marginsplot which I loosely based on this thread. https://www.statalist.org/forums/forum/general-stata-discussion/general/1368680-using-margins-with-restricted-cubic-splines

Code:
mkspline2 rcalpha = alphasit, cubic nknots(4) displayknots
 
gen alphasit1000 = round(1000*alphasit,1)
 
svy, subpop(include): regress bmi_12 c.rcalpha*##ib1.mvpagroup drage_12 dsex2_f deduc3_uni deduc3_tafe dethn3_oeng dethn3_oth doccup4_no doccup4_wc doccup4_bc dmarr2_no dalc3_hi dalc3_med
testparm rcalpha*  /*effect within mvpagorup == ref, 1*/
testparm mvpagroup#c.rcalpha* /*interaction, collective significance of all 3 terms used in the splines*/
qui margins , at(drage_12=57.41026 dsex2_f=1.105769 deduc3_uni=0.2596154 deduc3_tafe=0.4567308 dethn3_oeng=0.1153846 dethn3_oth=0.0721154 doccup4_no=0.3685897 doccup4_wc=0.2259615 doccup4_bc=0.1137821 dmarr2_no=0.2227564 dalc3_hi=0.2532051 dalc3_med=0.1746795)  over(mvpagroup alphasit1000)
marginsplot, xdimension(alphasit1000) bydimension(mvpagroup) recast(line) recastci(rarea)
-- > this gives us the interaction (including collective significance) the effect in the referent 'mvpa' (physical activity) group (including significance) and if I simply rerun with the other mvpa group as the referent I get the effect in the other mvpa group (including collective significance) and I’ve got some plots to visualise the effect within each group.

I stretched the graphs on the bottom to be the same x vs y axis dimensions. SEEM PRETTY SIMILAR?Just wanted to check if this made sense / was Kosher?

*** Interaction models & marginsplot carefully specified to fix all the covariates at their means but not to say what to do with rcalpha variables (instead use over alpha and over mvpa), gave the graphs on the top.

*** Stratified models with adjustrcspline give the graphs on the bottom.

Many thanks in advance! Array


p.s. (If you’re wondering what alphasit1000 is - it’s me working within the constraints of needing to plot integers. By *1000 then rounding it’s the same as rounding to three decimals which I think is maybe OK for plotting.