<?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: Adding conditions to PROC TRANSREG splines in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/434705#M22920</link>
    <description>&lt;P&gt;Alternatively: how would you go about doing this? (fitting a curve to data with the requirement that the curve "level off" at zero)&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2018 21:53:54 GMT</pubDate>
    <dc:creator>Schwa</dc:creator>
    <dc:date>2018-02-06T21:53:54Z</dc:date>
    <item>
      <title>Adding conditions to PROC TRANSREG splines</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/434655#M22918</link>
      <description>&lt;P&gt;New-ish SAS user.&lt;BR /&gt;&lt;BR /&gt;I need to generate some curves to fit some vaguely bell-shaped data. (I'm looking at female fertility by age, if that matters.) It looks like splines are the way to go, and PROC TRANSREG seems to be a great procedure to use here. What I'd like to do is add conditions that f(a)=f'(a)=0 for my curve, where a is either "endpoint" of my data (in this case, for a=14 and a=50). Two questions:&lt;BR /&gt;&lt;BR /&gt;1. Can I do this within PROC TRANSREG? And a follow-up question: if I need to generate several spline curves and display them on a single graph (say, one for each year or something), how would I do this with this procedure? (My thinking is that maybe I could save the curves on the fly and then write them to a single graph or something?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Is there a better procedure for this kind of thing? There are so many to choose from...&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 18:59:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/434655#M22918</guid>
      <dc:creator>Schwa</dc:creator>
      <dc:date>2018-02-06T18:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Adding conditions to PROC TRANSREG splines</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/434705#M22920</link>
      <description>&lt;P&gt;Alternatively: how would you go about doing this? (fitting a curve to data with the requirement that the curve "level off" at zero)&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 21:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/434705#M22920</guid>
      <dc:creator>Schwa</dc:creator>
      <dc:date>2018-02-06T21:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Adding conditions to PROC TRANSREG splines</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/434715#M22921</link>
      <description>&lt;P&gt;There is nothing built into transreg that does what you want.&amp;nbsp; The only way I have ever figured out to make transreg produce a function that passes through (or very close to) specific points is to add those points to the data set and give them a really big weight.&amp;nbsp; In the example code below, I add two points to the data, one at the minimum and one at the maximum.&amp;nbsp; I give those a big weight. Then, yes, you can create and output data set and create graphs with one or more functions by using PROC SGPLOT.&amp;nbsp; I only illustrate one function, but you can add more statements to get more.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
   do i = 1 to 100;
      x = normal(151);
      y = exp(-0.5 * x * x) + 0.1 + 0.1 * normal(151);
      output;
      end;
   run;

ods graphics on;
proc transreg data=x;
   model ide(y) = spl(x / nkn=3);
   output out=b p;
run;

proc means noprint data=x;
   output out=m(where=(_stat_ in ('MIN', 'MAX')));
   var x;
run;

data x2(drop=_stat_ min max);
   retain min max;
   if _n_ eq 1 then do;
      set m(keep=x _stat_ where=(_stat_='MIN'));
      min = x;
      set m(keep=x _stat_ where=(_stat_='MAX'));
      max = x;
      end;
   set x;
   w = 1;
   output;

   if abs(x - min) le 1e-8 or abs(x - max) le 1e-8 then do;
      w = 1e6;
      y = 0;
      output;
      end;
   run;

proc transreg data=x2 plots=fit(nocli);
   model ide(y) = spl(x / nkn=3);
   output out=b(where=(w=1)) p;
   weight w;
run;

proc sort data=b;
   by x;
   run;

proc sgplot;
   scatter y=y x=x;
   series y=py x=x;
   refline 0 / axis=y;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2018 22:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/434715#M22921</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2018-02-06T22:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Adding conditions to PROC TRANSREG splines</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/436898#M23055</link>
      <description>&lt;P&gt;Alright, yes, I thought of doing something like this, but I was hoping there was a nicer way. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 22:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Adding-conditions-to-PROC-TRANSREG-splines/m-p/436898#M23055</guid>
      <dc:creator>Schwa</dc:creator>
      <dc:date>2018-02-13T22:07:12Z</dc:date>
    </item>
  </channel>
</rss>

