<?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: Proc nlin method in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378035#M65489</link>
    <description>&lt;P&gt;Please explain what you mean by "doesn't work." Is there an ERROR or WARNING in the SAS log? &amp;nbsp;If so, please append the log.&lt;/P&gt;
&lt;P&gt;Is there non-convergence? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We also need to know what version of SAS you are running. Submit&lt;/P&gt;
&lt;P&gt;&amp;amp;put &amp;amp;=sysvlong;&lt;/P&gt;
&lt;P&gt;and look in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, since you did not post your data in the form of a DATA step, there could be an error in the way the data are read. The following program at SAS 9.4m4 works perfectly. Note that I added a BOUNDS statement to restrict two parameters, which I assume are&amp;nbsp;positive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input Time X;
datalines;
0	2.07936
0	1.795714
30	21.24958
30	22.44529
60	34.25629
60	33.70213
90	44.95228
90	44.56428
120	54.86515
120	55.98709
150	66.58977
150	62.09209
180	80.25785
180	77.43605
240	88.45111
240	88.8228
;
ods graphics off;
proc nlin data=Have maxiter=2000;
parms A=2.5 Km=0.004 B=65 C=1;
bounds Km C &amp;gt; 0;
model X = A + B * (1 - exp(-Km * Time))**C;
output out=IV p=yhat r=resid u95=upper l95=lower parms= A Km B C;
run;
quit;

proc sgplot data=IV;
scatter x=Time y=X;
series x=Time y=yhat;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 21 Jul 2017 09:27:06 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-07-21T09:27:06Z</dc:date>
    <item>
      <title>Proc nlin method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377649#M65470</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with samples taken over time which looks as follows (took out one ID to show what it looks like):&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Time&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;2.07936&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1.795714&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;21.24958&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;22.44529&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;34.25629&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;33.70213&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;90&lt;/TD&gt;&lt;TD&gt;44.95228&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;90&lt;/TD&gt;&lt;TD&gt;44.56428&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;54.86515&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;55.98709&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;66.58977&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;62.09209&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;180&lt;/TD&gt;&lt;TD&gt;80.25785&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;180&lt;/TD&gt;&lt;TD&gt;77.43605&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;240&lt;/TD&gt;&lt;TD&gt;88.45111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1703187-01&lt;/TD&gt;&lt;TD&gt;240&lt;/TD&gt;&lt;TD&gt;88.8228&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I am using the Nlin method to solve the following equation: X=A + B * (1 - Exp(-km * :Time)) ^ c.&lt;/P&gt;&lt;P&gt;My code then looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc nlin data=IV plots=all maxiter=2000;&lt;BR /&gt;parms A=2.5 Km=0.004 B=65 C=1;&lt;BR /&gt;model X= A&amp;nbsp;+ B&amp;nbsp;* (1 - exp(-Km * Time))**C;&lt;BR /&gt;output out=IV p=yhat r=resid u95=upper l95=lower&lt;BR /&gt;parms= A&amp;nbsp;Km B C;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This model will not fit properly if I try to run it on the dataset, however, if I change the Time values of my first time-point to for example 0.01 it does work. If I change them to 0.001 and run it again, it does not work anymore.&lt;/P&gt;&lt;P&gt;One of my collagues works in JMP and if he tries to fit the model on the original data it works perfectly, so I am really struggling to determine why it wont work in SAS, but more importantly, why it does fit when I change the first timepoint to something above 0. Does Nlin have issues with a 0 point??&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 20:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377649#M65470</guid>
      <dc:creator>GavinB</dc:creator>
      <dc:date>2017-07-20T20:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc nlin method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377862#M65474</link>
      <description>&lt;P&gt;You need to include DCt&amp;nbsp;in the input data set.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 17:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377862#M65474</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-07-20T17:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc nlin method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377917#M65478</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see I made a mistake when posting this, X in the table above is the DCt. I have adjusted that now, but that was already okay in my input file SAS. So the issues still remains......&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 20:27:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377917#M65478</guid>
      <dc:creator>GavinB</dc:creator>
      <dc:date>2017-07-20T20:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc nlin method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378035#M65489</link>
      <description>&lt;P&gt;Please explain what you mean by "doesn't work." Is there an ERROR or WARNING in the SAS log? &amp;nbsp;If so, please append the log.&lt;/P&gt;
&lt;P&gt;Is there non-convergence? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We also need to know what version of SAS you are running. Submit&lt;/P&gt;
&lt;P&gt;&amp;amp;put &amp;amp;=sysvlong;&lt;/P&gt;
&lt;P&gt;and look in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, since you did not post your data in the form of a DATA step, there could be an error in the way the data are read. The following program at SAS 9.4m4 works perfectly. Note that I added a BOUNDS statement to restrict two parameters, which I assume are&amp;nbsp;positive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input Time X;
datalines;
0	2.07936
0	1.795714
30	21.24958
30	22.44529
60	34.25629
60	33.70213
90	44.95228
90	44.56428
120	54.86515
120	55.98709
150	66.58977
150	62.09209
180	80.25785
180	77.43605
240	88.45111
240	88.8228
;
ods graphics off;
proc nlin data=Have maxiter=2000;
parms A=2.5 Km=0.004 B=65 C=1;
bounds Km C &amp;gt; 0;
model X = A + B * (1 - exp(-Km * Time))**C;
output out=IV p=yhat r=resid u95=upper l95=lower parms= A Km B C;
run;
quit;

proc sgplot data=IV;
scatter x=Time y=X;
series x=Time y=yhat;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 09:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378035#M65489</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-07-21T09:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc nlin method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378045#M65490</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of, thanks for replying so quickly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The model fits but refuses to go through the first points for some reason, which gives the following error message.&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10437i1896A5F9135FF2C8/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="output SAS Nlin.png" title="output SAS Nlin.png" /&gt;&lt;/P&gt;&lt;P&gt;This then leads to improper estimations of the parameters since it does not fit through the first points. It gives the first values as missing values. I feel like the answer is rather simple, but I cannot seem to grasp it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data has been read properly, the table shows the correct values and plotting the data also gives the proper graphs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im running this on a SAS server running SAS studio &lt;STRONG&gt;9.04.01M4P11092016&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 09:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378045#M65490</guid>
      <dc:creator>GavinB</dc:creator>
      <dc:date>2017-07-21T09:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc nlin method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378096#M65492</link>
      <description>&lt;P&gt;I see. So the issue is that the procedure prints:&lt;/P&gt;
&lt;P&gt;Execution Errors for OBS 1:&lt;/P&gt;
&lt;P&gt;Execution Errors for OBS 2:&lt;/P&gt;
&lt;P&gt;Note: Missing values were generated as a result of performing an operation on missing values. Each place is given by (number of times) AT (statement)/(line):(column).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now I am puzzled, too. If Km and C are free parameters, then the expression (1-&lt;/SPAN&gt;exp&lt;SPAN&gt;(-Km*Time))**C might not be a valid expression, since&amp;nbsp;a**b is potentially undefined when a&amp;lt;0.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, if you bound Km&amp;gt;0 and C&amp;gt;0, then the expression (1-exp(-Km*Time))**C ought to be a valid expression.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will have to think about this...or maybe someone who uses PROC NLIN more than me knows the answer. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 12:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378096#M65492</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-07-21T12:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Proc nlin method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378210#M65495</link>
      <description>&lt;P&gt;OK, I understand. The problem is not in evaluating the expression, it is in evaluating the derivative w.r.t C of the expression.&lt;/P&gt;
&lt;P&gt;Recall that if a&amp;gt;0, then d/dx(a^x) = a^x*ln(a). &amp;nbsp;In your case, the derivative is w.r.t C and a=1-exp(-Km*Time).&lt;/P&gt;
&lt;P&gt;The derivative is&lt;/P&gt;
&lt;P&gt;d/dC(a^C) = a^C*ln(a)&lt;/P&gt;
&lt;P&gt;which is only defined for a &amp;gt; 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can avoid the point of discontinuity by&amp;nbsp;modifying your PROC NLIN code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc nlin data=Have maxiter=2000;
parms A=2.5 Km=0.004 B=65 C=1;
bounds Km C &amp;gt;0;
expr = 1 - exp(-Km * Time);
if expr &amp;lt;= 0 then expr=1 - exp(-Km * 1e-12); /* nudge Time away from 0 */
model X = A + B * expr**C;
output out=IV p=yhat r=resid u95=upper parms= A Km B C;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378210#M65495</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-07-21T15:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc nlin method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378579#M65558</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This indeed seems to solve the problem for most of my parameters! Will look further into the ones that still give errors. Thanks for clearing things up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 05:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378579#M65558</guid>
      <dc:creator>GavinB</dc:creator>
      <dc:date>2017-07-24T05:42:18Z</dc:date>
    </item>
  </channel>
</rss>

