Hi folks - I am trying to understand and figure out how to actually code/test non-linearity between spline (cox proportional hazards regression) and linear models using LR tests. I have seen this described in papers, but the actual mechanics of it in Stata are still a little unclear to me.

For example, in this paper here (https://www.ahajournals.org/doi/full...AHA.120.020718) they look at this for a diet variable and CVD and state:

"We computed restricted cubic splines with 4 knots to visually assess the shape of association between ADPQS as a continuous variable (both time- varying average and 13- year change) and risk of CVD. Statistical significance of nonlinearity (ie, curvature) was tested by comparing the spline model with the linear model, and P values of <0.05 were regarded as statistically significant nonlinear relationship between the exposure and the outcome. Statistical significance of linearity was tested by comparing the linear model to the model including only the covariates, both using likelihood ratio tests."

They then report p-values for these results in text and with a figure (below).

"A monotonic decrease in CVD risk with time-varying average APDQS (P-nonlinearity=0.12 and P-linearity<0.001; Figure A) and the 13- year change in APDQS (P-nonlinearity=0.54 and P- linearity=0.04; Figure B) was observed in restricted cubic splines." Array




I know one can compare nested models to look at prediction level with LR tests (e.g. below link)...

https://stats.idre.ucla.edu/stata/fa...test-in-stata/
Code:
logit hiwrite female read
estimates store m1
logit hiwrite female read math science
estimates store m2 lrtest m1 m2  
... but how would one as per the above example paper compare a cox-regression linear model to a non-linear (restricted cubic spline) model using LR, and what is the relevance of the sentence "linearity was tested by comparing the linear model to the model including only the covariates"?

What would this Stata code look like in practice as a (quick/simple) example to compute these different p-values to compare the non-linear and linear models in this instance?

Thanks so much! I really appreciate your thoughts
Patrick