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) ;
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.
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?
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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.