Can someone help me to understand what is going wrong with the following code?
The code is to estimate the covariance parameters employing mixed model analysis with the classical animal model used in breeding. There are 3 fixed effects F1=2 levels, F2=11 levels and F3=2 levels. Individual animals (1413 Nos) are considered as random effects. am is the additive genetic relationship matrix or numerator relationship matrix. The same procedure from proc mixed using REML is tried to implement through the following code. The output from MIVQUE0 module is the starting value for the minimization of -2loglikelihood. I cannot understand why the following error happens.
This happens because your Function Module REML does not return a 1x1 matrix ie. a scalar. The NLPNRR Subroutine requires that. From the NLPNRR Documentation, you can see the small example program
proc iml;
start F_BETTS(x);
f = .01 * x[1] * x[1] + x[2] * x[2] - 100.;
return(f);
finish F_BETTS;
con = { 2. -50. . .,
50. 50. . .,
10. -1. 1. 10.};
x = {-1. -1.};
optn = {0 2};
call nlpnrr(rc,xres,"F_BETTS",x,optn,con);
quit;
If you change the BETTS Function Module to return a (2x1) vector instead of a scalar, you get that exact error:
proc iml;
start F_BETTS(x);
f = .01 * x[1] * x[1] + x[2] * x[2] - 100.;
return(f//f);
finish F_BETTS;
con = { 2. -50. . .,
50. 50. . .,
10. -1. 1. 10.};
x = {-1. -1.};
optn = {0 2};
call nlpnrr(rc,xres,"F_BETTS",x,optn,con);
quit;
So debug and rewrite your REML Function module to return a scalar
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.