BookmarkSubscribeRSS Feed
ayaaj
Calcite | Level 5

 

Hello,

I am trying to check the linearity assumption of my covariates as well as the PH assumption. Knowing that all my covariates are time varying (the value can change many times during the follow up) is it possible to check for the lineraity as well as PH assumption?

I am trying tu use this code:

 

ODS GRAPHICS ON;
proc phreg data=data1;
Model(start,stop)*event(0)=x1 x2 x3 x4 x5 x6;
assess var=(x1 x2 )/resample;
run;
ODS GRAPHICS Off;

 

But this code did not work with the counting process neither the programming statement code.

Is there any other way to plot martingal and shoenfeld residuals ?

Thank you in advance.

2 REPLIES 2
sfqg
SAS Employee

Hi there,

 

As printed in the log:

 

 

NOTE: Model assessment is not available with the counting process style of input. The ASSESS statement is ignored.

You can however still calculate the Martingale and Schoenfeld residuals by using the OUTPUT statement:

 

 


proc phreg data=data1;
Model(start,stop)*event(0)=x1 x2 x3 x4 x5 x6;
output out=output_dsn resmart=Mart RESSCH=schoenfeld;
run;

 

 

Next you will have to plot it for each variable, for example using PROC LOESS which plots us a nice smoothing spline to help discover the (residual) functional form of the covariate:

 

 ods output on;
proc loess data=Out1 plots(only)=(fit);
model Mart=x1 /CLM smooth=0.5;
ods output OutputStatistics=Results;
run;

You can do the same thing for plotting Schoenfeld residuals over time. If you need a formal test you can perform a simple linear regression where the dependent variable is the Schoenfeld residual and the independent variable is time. As an extra caveat introduced by working with time dependent covariates, you will have to reweight the rows in the dataset based on which proportion of the patient survival time they represen. Otherwise you would be introducing bias by having clustered rows belonging to the same patient.

Me personally I like to test covariates before I enter them in the model by fitting a null model and plotting the residuals. This allows you to gain insight in the true functional form of the covariate. To throw that all together it would look something like this:

 

 

	data _dummy_abt;
		set &table;
		dummy=0;
		keep dummy &var_time &var_event &var;
	run;

	proc phreg data=_dummy_abt;
		model &var_time*&var_event(0)=dummy;
		output out=_out resmart=rr 
			/order=data;
	run;

	ods graphics on;

	proc loess data=Out1 plots(only)=(fit);
		model resmart=x1 /CLM smooth=0.5;
		ods output OutputStatistics=Results;
	run;

	proc datasets lib=work;
		delete _dummy_abt _out;
	run;

 

You can write a macro to loop over the variables.

 

For more details on model assessment see Thomas R Fleming and David P Harrington. Counting processes and survival analysis, volume 8. Wiley Online Library, 1991.  

 

 

ayaaj
Calcite | Level 5

Hi,

Thank you for your help... it works for schoenfeld  residuals but for martingale residuals it  gave me many residuals for the same subject as shown in the table:

idstartstopx1martingale
1132r1
1355r2
15104r3
110197r4
119208r5
1202110.

 

Is it correct to plot martingale residuals with many residuals for each subject ? is there anyway to aggregate them ?

If i need to have one residual for each subject, can i sum the residuals per subject ?

Thank you in advance,

Aya

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 4456 views
  • 1 like
  • 2 in conversation