The TMODEL Procedure

Getting Started: TMODEL Procedure

(View the complete code for this example.)

One of the most powerful enhancements in PROC TMODEL compared to PROC MODEL is the ability to reduce the time required to perform computationally intensive tasks, such as estimating parameters in a nonlinear ordinary differential equation (ODE) model. This estimation task requires both the numerical integration of derivative variables in the model over time steps and the repeated evaluation of the time steps during the estimation’s minimization process. The following example estimates the parameters in a system of two coupled differential equations by using simulated data for four time series:


data soln;
   keep exprun t x y;
   length exprun $ 8;
   array experno[4] $ _temporary_ ( "one" "two" "three" "four" );
   call streaminit (1);
   do i = 1 to 4;
      exprun = experno[i];
      do t = 0 to 5 by 0.1;
         /* analytic solution for the ODE system */
         x = 1/2*(exp(-3*t) - exp(-t)) + rand('normal',0,0.01);
         y = 1/2*(exp(-3*t) + exp(-t)) + rand('normal',0,0.01);
         output;
      end;
   end;
run;
proc model outmodel=ode;
   endo x y;
   parms a b;
   g = exp (x + y);
   dert.x = -a*x - log (g);
   dert.y = -b*y - log (g);
quit;

proc model data=soln model=ode;
   fit / time=t dynamic;
quit;

proc tmodel data=soln model=ode;
   crosssection exprun;
   fit / time=t dynamic;
quit;

The model file Work.ODE is created and used in this example to avoid redundant specification of the model program. Although the ODE model and data are identical in the PROC MODEL and PROC TMODEL steps, you must specify the CROSSSECTION statement to take advantage of the multithreading capabilities of PROC TMODEL. Figure 1 shows how much faster PROC TMODEL performs this estimation by integrating the model over each of the four time series concurrently. Real time measures how long it takes to execute the PROC step, and CPU time is a measure of the computing resources that the PROC step consumes.

Figure 1: Performance Comparison of PROC MODEL and PROC TMODEL

NOTE: PROCEDURE MODEL used (Total process time):                                
      real time           4.18 seconds                                          
      cpu time            4.10 seconds                                          
NOTE: PROCEDURE TMODEL used (Total process time):                               
      real time           4.14 seconds                                          
      cpu time            11.34 seconds                                         


Last updated: December 20, 2021