<?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 Interaction with restricted cubic spline - comparison between SAS and R in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673651#M32235</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;When performing the same cox-regression in SAS (SAS-STAT 15.1) and i R (including and interaction with a 3 knot restricted cubic spline), I receive different parameter estimates (i.e on age_spline 2). In my example below I have used the dataset=WHAS500 found on this website (&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-survival/" target="_blank" rel="noopener"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-survival/&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;To harmonize the models (and the splines) between SAS and R I have used knots according to&amp;nbsp;&lt;SPAN&gt;Harrell's scheme (&lt;A href="https://blogs.sas.com/content/iml/2019/02/18/regression-restricted-cubic-splines-sas.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2019/02/18/regression-restricted-cubic-splines-sas.html&lt;/A&gt;) and set both TIES to EFRON&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SAS-code&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc phreg data = whas500;
effect age_spline = spline(age/ details naturalcubic basis=tpf(noint) 
knotmethod=percentilelist(10 50 90) );
model lenfol*fstat(0) = gender|age_spline /rl ties=EFRON; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;STRONG&gt;R-code&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;fit &amp;lt;- coxph(Surv(LENFOL, FSTAT) ~ GENDER*rcs(AGE,3), data = whas500)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="parameter_comparison.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47823iB9C7C85113E0FE0C/image-size/large?v=v2&amp;amp;px=999" role="button" title="parameter_comparison.png" alt="parameter_comparison.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be very thankful if someone can help me explain the observed differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jul 2020 09:32:59 GMT</pubDate>
    <dc:creator>Thomas45</dc:creator>
    <dc:date>2020-07-31T09:32:59Z</dc:date>
    <item>
      <title>Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673651#M32235</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;When performing the same cox-regression in SAS (SAS-STAT 15.1) and i R (including and interaction with a 3 knot restricted cubic spline), I receive different parameter estimates (i.e on age_spline 2). In my example below I have used the dataset=WHAS500 found on this website (&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-survival/" target="_blank" rel="noopener"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-survival/&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;To harmonize the models (and the splines) between SAS and R I have used knots according to&amp;nbsp;&lt;SPAN&gt;Harrell's scheme (&lt;A href="https://blogs.sas.com/content/iml/2019/02/18/regression-restricted-cubic-splines-sas.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2019/02/18/regression-restricted-cubic-splines-sas.html&lt;/A&gt;) and set both TIES to EFRON&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SAS-code&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc phreg data = whas500;
effect age_spline = spline(age/ details naturalcubic basis=tpf(noint) 
knotmethod=percentilelist(10 50 90) );
model lenfol*fstat(0) = gender|age_spline /rl ties=EFRON; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;STRONG&gt;R-code&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;fit &amp;lt;- coxph(Surv(LENFOL, FSTAT) ~ GENDER*rcs(AGE,3), data = whas500)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="parameter_comparison.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47823iB9C7C85113E0FE0C/image-size/large?v=v2&amp;amp;px=999" role="button" title="parameter_comparison.png" alt="parameter_comparison.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be very thankful if someone can help me explain the observed differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 09:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673651#M32235</guid>
      <dc:creator>Thomas45</dc:creator>
      <dc:date>2020-07-31T09:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673657#M32236</link>
      <description>&lt;P&gt;&amp;nbsp;Most likely, the algorithms used are not the same. Or the options used are not the same.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 10:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673657#M32236</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-31T10:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673691#M32239</link>
      <description>&lt;P&gt;All of the values I see except the age_spline 2 look the same within some sort of rounding difference.&amp;nbsp; The interesting thing about age_spline 2 is that the chi square is a match (again within rounding error) to the Z value (in R) squared, as they are for the other terms.&amp;nbsp; This does make me think that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; has identified the issue that the algorithm for constructing the splines may be different.&amp;nbsp; However, the interaction with gender terms do match pretty well for age_spline 1 and show the same issue for age_spline 2.&amp;nbsp; I think I have just turned your short question into a long one, without providing much insight.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This looks like a job for the Cross Validated site at this point, unless one of the Super Freq's who knows the algorithms behind both can jump in to help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 12:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673691#M32239</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2020-07-31T12:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673779#M32240</link>
      <description>&lt;P&gt;Thanks for you suggestions!&lt;/P&gt;&lt;P&gt;I have now also posted this on Cross validated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 16:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673779#M32240</guid>
      <dc:creator>Thomas45</dc:creator>
      <dc:date>2020-07-31T16:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673780#M32241</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Any Super Freq's who knows&amp;nbsp;the algorithms behind restricted cubic splines in SAS (knotmethod=percentlielist)?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/T&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 16:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673780#M32241</guid>
      <dc:creator>Thomas45</dc:creator>
      <dc:date>2020-07-31T16:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673900#M32247</link>
      <description>&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 12:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673900#M32247</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-01T12:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673942#M32250</link>
      <description>&lt;P&gt;As Paige says, it is often very difficult to compare across software implementations because of difference in defaults and algorithms. You basically have to be intimately familiar with the implementation in both software products.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, as I mention in one of my blog posts,&amp;nbsp;&lt;SPAN&gt;the basis functions that are generated by the EFFECT statement are not equal to the basis functions created by Harrel's %RCSPLINE macro, but they are equivalent. The EFFECT statement uses the definition from&amp;nbsp;&lt;/SPAN&gt;&lt;A href="http://statweb.stanford.edu/~tibs/ElemStatLearn/printings/ESLII_print10.pdf" target="_blank"&gt;&lt;EM&gt;The Elements of Statistical Learning&lt;/EM&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;(Hastie, Tibshirani, and Friedman, 2009, 2nd Ed, pp. 144-146). The %RCSPLINE macro implements scaled versions of the basis function. Thus parameter estimates will be different but the predicted values will be the same.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you not only need to know the differences in the algorithm that you are investigating, but every algorithm that is USED by that algorithm! Since you are looking at placing the knots at percentiles, and since you explicitly mentioned handling TIES in the data, I will point out that SAS and R use different default definitions of percentiles. For details, &lt;A href="https://blogs.sas.com/content/iml/2017/05/24/definitions-sample-quantiles.html" target="_self"&gt;see my article on the 9 standard definitions of percentiles&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have time to research this issue, but I wish you luck. I suggest you to investigate whether the PREDICTED value are approximately the same. If so, they represent the same model even if the parameterization is different. You might want to run the model for a simulated data set that has no duplicates, to eliminate the tied values/percentile issue.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 18:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/673942#M32250</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-08-01T18:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/675582#M32363</link>
      <description>&lt;P&gt;Thank you all for your comments and suggestions!&lt;/P&gt;&lt;P&gt;I have analysed the predicted estimates and there are approx the same between R and SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;P&gt;/Thomas&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 13:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/675582#M32363</guid>
      <dc:creator>Thomas45</dc:creator>
      <dc:date>2020-08-10T13:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Interaction with restricted cubic spline - comparison between SAS and R</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/675595#M32368</link>
      <description>&lt;P&gt;Great news. You can indicate that the problem is resolved by marking one of the responses as the solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 13:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Interaction-with-restricted-cubic-spline-comparison-between-SAS/m-p/675595#M32368</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-08-10T13:54:50Z</dc:date>
    </item>
  </channel>
</rss>

