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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.