Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
user_123221
Calcite | Level 5

Hi,

 

there is a procedure to calculate the determinant and I want to use it within the nlmixed procedure. To give an example I modified an nlmixed example from the doc. This doesn't make much sense but illustrates my point. The following works:

 

proc nlmixed data=theoph;
   parms beta1=-3.22 beta2=0.47 beta3=-2.45
         s2b1 =0.03  cb12 =0    s2b2 =0.4 s2=0.5;
   cl   = exp(beta1 + b1);
   ka   = exp(beta2 + b2);
   ke   = exp(beta3);
   pred = cl*beta1 - ka*ke;
   model conc ~ normal(pred,s2);
   random b1 b2 ~ normal([0,0],[s2b1,cb12,s2b2]) subject=subject;
run;

But when I substitute "cl*beta1 - ka*ke" by a seemingly equivalent call to det I get an error.

proc nlmixed data=theoph;
   parms beta1=-3.22 beta2=0.47 beta3=-2.45
         s2b1 =0.03  cb12 =0    s2b2 =0.4 s2=0.5;
   cl   = exp(beta1 + b1);
   ka   = exp(beta2 + b2);
   ke   = exp(beta3);
   array A [2,2];
   A[1,1] = cl;
   A[1,2] = ka;
   A[2,1] = ke;
   A[2,2] = beta1;
   call det(A, pred);
   model conc ~ normal(pred,s2);
   random b1 b2 ~ normal([0,0],[s2b1,cb12,s2b2]) subject=subject;
run;

The error is:

NOTE: Array argument A is ignored for the derivative of the 'DET' function.
ERROR: Random effect b1 not found in the model.

Is there a way to overcome this? Of course in my real code I want to calculate a larger determinant and also use other matrix operations.

 

Thanks

2 REPLIES 2
Rick_SAS
SAS Super FREQ

I've not used the matrix capabilities of PROC NLMIXED, but I think the problem is that when you assign the elements of A by using A[1,1]=c1, etc.  The program needs to know how to take the derivative of  DET(A), and to do that it must know the symbols for each element of A. Try the following syntax, which associates the elements of matrix A to symbols in row-major order:

 

array A [2,2] cl ka ke beta1;

 

user_123221
Calcite | Level 5

When I specify the array in the way you suggested the "NOTE" message disappears but I still get

ERROR: Random effect b1 not found in the model.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1613 views
  • 0 likes
  • 2 in conversation