<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: plot martingal and shoenfeld residuals in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/plot-martingal-and-shoenfeld-residuals/m-p/248838#M268631</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thank you for your help... it works for schoenfeld&amp;nbsp; residuals but for martingale residuals it&amp;nbsp; gave me many residuals for the same subject as shown in the table:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;start&lt;/TD&gt;&lt;TD&gt;stop&lt;/TD&gt;&lt;TD&gt;x1&lt;/TD&gt;&lt;TD&gt;martingale&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;r1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;r2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;r3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;19&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;r4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;19&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;r5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it correct to plot martingale residuals with many residuals for each subject ? is there anyway to aggregate them ?&lt;/P&gt;&lt;P&gt;If i need to have one residual for each subject, can i sum the residuals per subject ?&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;Aya&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2016 11:47:57 GMT</pubDate>
    <dc:creator>ayaaj</dc:creator>
    <dc:date>2016-02-09T11:47:57Z</dc:date>
    <item>
      <title>plot martingal and shoenfeld residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/plot-martingal-and-shoenfeld-residuals/m-p/247391#M268629</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;I am trying tu use this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ODS GRAPHICS ON;&lt;BR /&gt;proc phreg data=data1;&lt;BR /&gt;Model(start,stop)*event(0)=x1 x2 x3 x4 x5 x6;&lt;BR /&gt;assess var=(x1 x2 )/resample;&lt;BR /&gt;run;&lt;BR /&gt;ODS GRAPHICS Off;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this code did not work with the counting process neither the programming statement code.&lt;/P&gt;&lt;P&gt;Is there any other way to plot martingal and shoenfeld residuals ?&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Feb 2016 09:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/plot-martingal-and-shoenfeld-residuals/m-p/247391#M268629</guid>
      <dc:creator>ayaaj</dc:creator>
      <dc:date>2016-02-02T09:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: plot martingal and shoenfeld residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/plot-martingal-and-shoenfeld-residuals/m-p/248601#M268630</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As printed in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Model assessment is not available with the counting process style of input. The ASSESS statement is ignored.
&lt;/PRE&gt;
&lt;P&gt;You can however still calculate the Martingale and Schoenfeld residuals by using the OUTPUT statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;proc phreg data=data1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Model(start,stop)*event(0)=x1 x2 x3 x4 x5 x6;&lt;/SPAN&gt;&lt;BR /&gt;output out=output_dsn resmart=Mart &lt;STRONG&gt;RESSCH=schoenfeld&lt;/STRONG&gt;;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; ods output on;&lt;BR /&gt; proc loess data=Out1 plots(only)=(fit);&lt;BR /&gt;   model Mart=x1 /CLM smooth=0.5;&lt;BR /&gt;   ods output OutputStatistics=Results;&lt;BR /&gt; run;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;You can do the same thing for plotting Schoenfeld residuals over&amp;nbsp;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.&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;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:&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	data _dummy_abt;
		set &amp;amp;table;
		dummy=0;
		keep dummy &amp;amp;var_time &amp;amp;var_event &amp;amp;var;
	run;

	proc phreg data=_dummy_abt;
		model &amp;amp;var_time*&amp;amp;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;
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can write a macro to loop over the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more details on model assessment see&amp;nbsp;Thomas R Fleming and David P Harrington. Counting processes and survival analysis, volume 8.&amp;nbsp;Wiley Online Library, 1991. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 01:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/plot-martingal-and-shoenfeld-residuals/m-p/248601#M268630</guid>
      <dc:creator>sfqg</dc:creator>
      <dc:date>2016-02-08T01:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: plot martingal and shoenfeld residuals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/plot-martingal-and-shoenfeld-residuals/m-p/248838#M268631</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thank you for your help... it works for schoenfeld&amp;nbsp; residuals but for martingale residuals it&amp;nbsp; gave me many residuals for the same subject as shown in the table:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;start&lt;/TD&gt;&lt;TD&gt;stop&lt;/TD&gt;&lt;TD&gt;x1&lt;/TD&gt;&lt;TD&gt;martingale&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;r1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;r2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;r3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;19&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;r4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;19&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;r5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it correct to plot martingale residuals with many residuals for each subject ? is there anyway to aggregate them ?&lt;/P&gt;&lt;P&gt;If i need to have one residual for each subject, can i sum the residuals per subject ?&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;Aya&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 11:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/plot-martingal-and-shoenfeld-residuals/m-p/248838#M268631</guid>
      <dc:creator>ayaaj</dc:creator>
      <dc:date>2016-02-09T11:47:57Z</dc:date>
    </item>
  </channel>
</rss>

