<?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: Parameter estimation with proc model and ODEs in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/295870#M1895</link>
    <description>&lt;P&gt;I got what look like satisfactory results by changing the ENDOGENOUS statement to a PARAMETERS statement. &amp;nbsp;I'm pretty sure that SAS expects endogenous variables to be part of the input dataset here, so by shifting to PARAMETERS, it fits those at t=0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve Denham&lt;/P&gt;</description>
    <pubDate>Thu, 01 Sep 2016 15:00:15 GMT</pubDate>
    <dc:creator>SteveDenham</dc:creator>
    <dc:date>2016-09-01T15:00:15Z</dc:date>
    <item>
      <title>Parameter estimation with proc model and ODEs</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/295556#M1892</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to fit a dataset with proc model and ordinary differential equations, but somehow it does not work.&lt;/P&gt;&lt;P&gt;SAS complains that I don't have the values A1 and A2 in the dataset, but they can't be in the dataset. Any ideas? The dataset and the code is attached below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;&lt;P&gt;Thorsten&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ata step01;&lt;BR /&gt;INPUT time &amp;nbsp;&amp;nbsp; &amp;nbsp;conc;&lt;BR /&gt;datalines;&lt;BR /&gt;0.1&amp;nbsp;&amp;nbsp; &amp;nbsp;1.50&lt;BR /&gt;0.2&amp;nbsp;&amp;nbsp; &amp;nbsp;3.20&lt;BR /&gt;0.4&amp;nbsp;&amp;nbsp; &amp;nbsp;4.30&lt;BR /&gt;0.6&amp;nbsp;&amp;nbsp; &amp;nbsp;5.10&lt;BR /&gt;0.8&amp;nbsp;&amp;nbsp; &amp;nbsp;5.40&lt;BR /&gt;1&amp;nbsp;&amp;nbsp; &amp;nbsp;5.20&lt;BR /&gt;1.2&amp;nbsp;&amp;nbsp; &amp;nbsp;5.00&lt;BR /&gt;1.4&amp;nbsp;&amp;nbsp; &amp;nbsp;4.80&lt;BR /&gt;2&amp;nbsp;&amp;nbsp; &amp;nbsp;4.00&lt;BR /&gt;3&amp;nbsp;&amp;nbsp; &amp;nbsp;2.50&lt;BR /&gt;4&amp;nbsp;&amp;nbsp; &amp;nbsp;1.50&lt;BR /&gt;5&amp;nbsp;&amp;nbsp; &amp;nbsp;1.00&lt;BR /&gt;6&amp;nbsp;&amp;nbsp; &amp;nbsp;0.62&lt;BR /&gt;7&amp;nbsp;&amp;nbsp; &amp;nbsp;0.40&lt;BR /&gt;8&amp;nbsp;&amp;nbsp; &amp;nbsp;0.25&lt;BR /&gt;10&amp;nbsp;&amp;nbsp; &amp;nbsp;0.10&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc model data=step01;&lt;BR /&gt;ENDOGENOUS A1 400 A2 0 ;&lt;BR /&gt;dert.A1 = -ka * A1;&lt;BR /&gt;dert.A2 =&amp;nbsp; ka * A1 - (CL/V2)*A2;&lt;BR /&gt;CONC=A2/V2;&lt;BR /&gt;FIT CONC start=(KA 2.5 CL 20 V2 50) ;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 16:07:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/295556#M1892</guid>
      <dc:creator>thorstenlehr</dc:creator>
      <dc:date>2016-08-31T16:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter estimation with proc model and ODEs</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/295870#M1895</link>
      <description>&lt;P&gt;I got what look like satisfactory results by changing the ENDOGENOUS statement to a PARAMETERS statement. &amp;nbsp;I'm pretty sure that SAS expects endogenous variables to be part of the input dataset here, so by shifting to PARAMETERS, it fits those at t=0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve Denham&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 15:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/295870#M1895</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2016-09-01T15:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter estimation with proc model and ODEs</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/296466#M1898</link>
      <description>&lt;P&gt;Dear Steve,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many thanks. It works perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I can add a second input/pulse (i.e. a drug dosing) to the first differential equation after a certain time, e.g. 12 hours? How can I integrate this into a dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;Thorsten&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2016 07:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/296466#M1898</guid>
      <dc:creator>thorstenlehr</dc:creator>
      <dc:date>2016-09-05T07:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter estimation with proc model and ODEs</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/299959#M1934</link>
      <description>&lt;P&gt;Thorsten,&lt;/P&gt;
&lt;P&gt;I was surprised to see that Steve's suggestion to change the ENDO statement into a PARMS statement does allow PROC MODEL to estimate this one compartment model; however, I would not recommend this approach as it exploits an unintended side effect in PROC MODEL and may not work in the future.&lt;/P&gt;
&lt;P&gt;The more standard way of estimating this model would be to include the unobserved values, a1 and a2, in the data set:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data step02;
   set step01;
   a1 = .;
   a2 = .;
run;   

proc model data=step02;
   endo a1 400 a2 0;
   ...
   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would also like to point out that neither of these approaches may be exactly what you want. Presumably, in your model the dose is administered at time = 0.&amp;nbsp; In your code the STEP01 data set's first observation is at time=0.1.&amp;nbsp; That means when PROC MODEL integrates these ODEs it uses a1=400, and a2=0 as the initial conditions at time=0.1.&amp;nbsp; To set the initial conditions a1=400, and a2=0&amp;nbsp;at time=0 you should add an extra observation with time=0 and conc=0 to the top of your data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding adding a pulse, or bolus, dose to the first equation you could use code like the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dert.A1 = -ka * A1 + dose*dirac(time - tbolus);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;after first defining a dirac function using PRC FCMP:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.funcs.f;
  function dirac(args[*]) varargs;
     x = args[1];
     if dim (args) = 1 then
         delta = 1e-6;
     else
        delta = args[2];
     if abs(x) &amp;lt; delta then
         f = (delta - abs(x))/(delta*delta);
     else
         f = 0;
     return (f);
  endsub;
run;

options cmplib=funcs;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You would need to define the TBOLUS, and DOSE variables either in your data set, or your model program.&lt;/P&gt;
&lt;P&gt;Marc&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 20:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/299959#M1934</guid>
      <dc:creator>kessler</dc:creator>
      <dc:date>2016-09-21T20:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter estimation with proc model and ODEs</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/300819#M1943</link>
      <description>&lt;P&gt;Sweet answer to use FCMP to come up with a Dirac function for a pulse input. &amp;nbsp;That's something I wish I had known about $) years ago (of course, there was no PROC MODEL then, let alone PROC FCMP).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve Denham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 17:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Parameter-estimation-with-proc-model-and-ODEs/m-p/300819#M1943</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2016-09-26T17:25:30Z</dc:date>
    </item>
  </channel>
</rss>

