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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.