08-31-2016 12:07 PM
I'm trying to fit a dataset with proc model and ordinary differential equations, but somehow it does not work.
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.
Many thanks in advance.
INPUT time conc;
proc model data=step01;
ENDOGENOUS A1 400 A2 0 ;
dert.A1 = -ka * A1;
dert.A2 = ka * A1 - (CL/V2)*A2;
FIT CONC start=(KA 2.5 CL 20 V2 50) ;
09-01-2016 11:00 AM
I got what look like satisfactory results by changing the ENDOGENOUS statement to a PARAMETERS statement. 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.
09-05-2016 03:59 AM
many thanks. It works perfectly.
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?
09-21-2016 04:19 PM
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.
The more standard way of estimating this model would be to include the unobserved values, a1 and a2, in the data set:
data step02; set step01; a1 = .; a2 = .; run; proc model data=step02; endo a1 400 a2 0; ...
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. In your code the STEP01 data set's first observation is at time=0.1. That means when PROC MODEL integrates these ODEs it uses a1=400, and a2=0 as the initial conditions at time=0.1. To set the initial conditions a1=400, and a2=0 at time=0 you should add an extra observation with time=0 and conc=0 to the top of your data set.
Regarding adding a pulse, or bolus, dose to the first equation you could use code like the following:
dert.A1 = -ka * A1 + dose*dirac(time - tbolus);
after first defining a dirac function using PRC FCMP:
proc fcmp outlib=work.funcs.f; function dirac(args[*]) varargs; x = args; if dim (args) = 1 then delta = 1e-6; else delta = args; if abs(x) < delta then f = (delta - abs(x))/(delta*delta); else f = 0; return (f); endsub; run; options cmplib=funcs;
You would need to define the TBOLUS, and DOSE variables either in your data set, or your model program.
09-26-2016 01:25 PM
Sweet answer to use FCMP to come up with a Dirac function for a pulse input. That's something I wish I had known about $) years ago (of course, there was no PROC MODEL then, let alone PROC FCMP).