BookmarkSubscribeRSS Feed
blund
Obsidian | Level 7

The following code appeared in a 2024 WUSS presentation (below).

When running SAS OnDemand for Academics I get this IML error

ERROR: Invocation of unresolved module NLPSOLVE

Can someone provide a replacement IML function?

 

PROC IML;

start LL(param) global(x); /* normal log likelihood */

mu = param[1]; sigma = param[2];

LL = sum( logpdf("Normal", x, mu, sigma) );

return( -LL ); /* minimize -LL */

finish;

use Sashelp.Iris; /* read sample data */

read all var {SepalWidth} into x;

p = {35 5.5}; /* guess (mu, sigma), sigma>0 */

call nlpsolve(rc, soln, "LL", p) L={. 0}; /* sigma>0 */

print soln;

1 REPLY 1
Rick_SAS
SAS Super FREQ

Sure. ODA is running SAS 9.4, so use the NLPNRA procedure, as shown in 

Maximum likelihood estimation in SAS/IML - The DO Loop

PROC IML;
start LL(param) global(x); /* normal log likelihood */
   mu = param[1]; sigma = param[2];
   LL = sum( logpdf("Normal", x, mu, sigma) );
   return( -LL ); /* minimize -LL */
finish;

use Sashelp.Iris; /* read sample data */
read all var {SepalWidth} into x;

p = {35 5.5}; /* guess (mu, sigma), sigma>0 */
/*     mu-sigma constraint matrix */
con = { .   0,  /* lower bounds: -infty < mu; 0 < sigma */
        .   .}; /* upper bounds:  mu < infty; sigma < infty */
call nlpnra(rc, soln, "LL", p) BLC=con;
print soln;

To understand where the SUM(LOGPDF(...)) function call comes from, see

Two simple ways to construct a log-likelihood function in SAS - The DO Loop

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Multiple Linear Regression in SAS

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 73 views
  • 0 likes
  • 2 in conversation