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.

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1735 views
  • 0 likes
  • 2 in conversation