Obsidian | Level 7

## how to model nonlinear association for time-varying covariates via cox regression analysis

Dear all,

I am doing a cox regression to explore if there is a nonlinear assocaition between BMI （continuous variable）and mortality. I want to model BMI as a time-dependent variable as it has been measured multiple times during follow-up. Does anyone know how to model nonlinear association for a  time-varying variable in cox regression analysis? Can I use restricted cubic spine methods?  Thanks a lot !

Feng Liang

5 REPLIES 5
SAS Super FREQ

## Re: how to model nonlinear association for time-varying covariates via cox regression analysis

PROC PHREG has two methods to handle time-dependent variables. See this example and this example in the PHREG doc. Regarding nonlinearity, PROC PHREG supports the EFFECT statement, which can be used to introduce lag effects and splines. However, I confess that I have not thought about what a spline effect means for a time-dependent covariate, or even if it makes sense. perhaps someone else can comment on whether building a spline effect makes sense in this context.

Obsidian | Level 7

## Re: how to model nonlinear association for time-varying covariates via cox regression analysis

Thank you !
Obsidian | Level 7

## Re: how to model nonlinear association for time-varying covariates via cox regression analysis

Dear Rick,

When using 'effect' to construct new variables (columns) in SAS "Proc Phreg", do you know how to output these variables into a dataset? Thanks!

Regards,

Feng Liang

Obsidian | Level 7

## Re: how to model nonlinear association for time-varying covariates via cox regression analysis

Dear Rick,

I am thinking whether it is possible that I construct cubic spline terms( variables)first for BMI measured at each time point, then output these variables into a new dataset, and finally create time-varying BMI. That's why I am wondering if these newly created variables can be output into a dataset. Thank you !

Best Regards,

Feng Liang

SAS Super FREQ

## Re: how to model nonlinear association for time-varying covariates via cox regression analysis

Yes, you can write the spline effects to a data set. It is called writing the "design matrix." I suggest you generate the design matrix by using PROC GLMSELECT, which supports an OUTDESIGN= option, like this

`outdesign(addinputvars fullmodel)=DesignMatrix;`

You can use the SELECTION=NONE option on the MODEL statement to force the procedure to output all the variables on the model step, in addition to the spline effects. This is shown in the section "Write the spline basis functions to a SAS data set" of the article "Regression with restricted cubic splines in SAS."

PROC GLMSELECT is one of several methods to generate a design matrix in SAS, but I like it because it also creates a macro variable that names the columns of the design matrix.

Discussion stats
• 5 replies
• 1046 views
• 0 likes
• 2 in conversation