turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- plot martingal and shoenfeld residuals

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-02-2016 04:48 AM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ayaaj

02-07-2016 08:23 PM

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=MartRESSCH=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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to sfqg

02-09-2016 06:47 AM

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:

id | start | stop | x1 | martingale |

1 | 1 | 3 | 2 | r1 |

1 | 3 | 5 | 5 | r2 |

1 | 5 | 10 | 4 | r3 |

1 | 10 | 19 | 7 | r4 |

1 | 19 | 20 | 8 | r5 |

1 | 20 | 21 | 10 | . |

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