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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.