<?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: Anyone could help me to solve this program code for natural cubic spline? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614500#M18607</link>
    <description>&lt;P&gt;Hi, thanks for your reply. I checked it and there were just two levels of COPD, Yes and No. Therefore I still did not know the problem.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 31 Dec 2019 01:25:50 GMT</pubDate>
    <dc:creator>cjchung</dc:creator>
    <dc:date>2019-12-31T01:25:50Z</dc:date>
    <item>
      <title>Anyone could help me to solve this program code for natural cubic spline?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614348#M18585</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello, everyone, I want to explore the association between PM2.5 (X) and COPD (Y).&lt;/P&gt;&lt;P&gt;I defined the variable, PM2.5 as non-linear and treated with a natural cubic spline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;COPD.match_newcopd is my data file. Here is the code....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=COPD.match_newcopd 
out=cubic (keep=copd pm25a mari_g diab hear Arthritis asthma cancer smk_g drk_g nut_g);
by pm25a;
run;
ods select Model ANOVA ParameterEstimates SplineKnots;
proc logistic data=cubic outdesign=SplineBasis;
effect spl = spline(pm25a / naturalcubic basis=tpf(noint) details knotmethod=EQUAL(5)) ; 
model COPD (event ='1')= spl /SELECTION = none;
output out=cubicOut5 predicted=Fit upper=u lower=l; /* output predicted values for graphing */
effectplot fit;
quit;

data a; set cubicout;
Fitexp=exp(Fit);
uexp=exp(u);
lexp=exp(l);
data copd.multipm; set work.a;run;

proc sort data=work.a; by pm25a; 
title "Restricted Cubic Spline Regression";
ods graphics/height=6.5in width=10in imagename="Figure2" border=off;
proc sgplot data=a noautolegend;
where Fitexp ^=.;
band x = pm25a lower=Lexp upper=Uexp;
xaxis label='PM2.5 (ug/m3)';
yaxis label='Risk of COPD' ;
series x=pm25a y=Fitexp / curvelabel = "Predicted value";
series x=pm25a y=uexp / curvelabel = "Upper CL";
series x=pm25a y=lexp / curvelabel = "Lower CL";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question 1: When I add the confounders (such as marriage) in the logistic model, I will get the terrible figure......&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like: model COPD (event ='1')= spl marriage /SELECTION = none;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is anything wrong with the above code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question 2: How I choose the best model with knots=3 or 5 by comparing the different AIC values?&amp;nbsp; How I write the SAS code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Figure231.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35078i75335ECC14FA3770/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Figure231.png" alt="Figure231.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 06:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614348#M18585</guid>
      <dc:creator>cjchung</dc:creator>
      <dc:date>2019-12-30T06:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Anyone could help me to solve this program code for natural cubic spline?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614454#M18591</link>
      <description>&lt;P&gt;Just a guess. You might have more than two levels for COPD. What happens if you add the statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;where COPD in (0, 1);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in your call to proc logistic?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 20:31:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614454#M18591</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-12-30T20:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Anyone could help me to solve this program code for natural cubic spline?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614500#M18607</link>
      <description>&lt;P&gt;Hi, thanks for your reply. I checked it and there were just two levels of COPD, Yes and No. Therefore I still did not know the problem.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 01:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614500#M18607</guid>
      <dc:creator>cjchung</dc:creator>
      <dc:date>2019-12-31T01:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Anyone could help me to solve this program code for natural cubic spline?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614513#M18611</link>
      <description>&lt;P&gt;OK, I think the problem is the superposition of predicted values for diffrent &lt;EM&gt;marriage&lt;/EM&gt; groups. Try sgpanel:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=work.a; 
by marriage pm25a; 
run;

title "Restricted Cubic Spline Regression";
ods graphics/height=6.5in width=10in imagename="Figure2" border=off;
proc sgpanel data=a noautolegend;
where Fitexp ^=.;
panelby marriage;
band x = pm25a lower=Lexp upper=Uexp;
colaxis label='PM2.5 (ug/m3)';
rowaxis label='Risk of COPD' ;
series x=pm25a y=Fitexp / curvelabel = "Predicted value";
series x=pm25a y=uexp / curvelabel = "Upper CL";
series x=pm25a y=lexp / curvelabel = "Lower CL";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or call proc sgplot with a BY marriage statement.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 04:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Anyone-could-help-me-to-solve-this-program-code-for-natural/m-p/614513#M18611</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-12-31T04:54:19Z</dc:date>
    </item>
  </channel>
</rss>

