Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 04-10-2014 05:31 PM
(1380 views)

Hii,

I used Proc NLMIXED for a non linear model, and wanted to talk about how it 'finds' the parameter estimates with maximum likelihood.

So I thought I'd look at a simple example: finding the mean and variance of a normally distributed variable "r".

I used Proc NLMIXED and found the variable is N(-0.6458, 0.4080^2), as I expected. The "NegLogLike" appears to be 62.6976.

I then used Proc IML to find the same information, with the desire to make a plot of "what's happening" as in http://blogs.sas.com/content/iml/2011/10/12/maximum-likelihood-estimation-in-sasiml/

I did all this successfully (or so I thought) and made a pretty plot, then compared the output and realised I found my variable r ~ N(-0.6458, 0.4080^2) as desired, but "Value of Objective Function = 47.575023947" which I expected to be 62.6... as above.

I have used the same optimisation technique each time - Dual Quasi-Newton - so I don't see what I'm doing wrong or where the differences can be attributed to?

Can anyone please help me? (That's you Ricky <333 hahah)

Thanks,

Katie xx

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I think the main problem is that you have missed out the factor of 2 pi in the log-likelihood function. If I substitute:

f = - n # log(2 # constant('pi') # sigma2) /2 - ssq(c) / (2 # sigma2);

in the LogLik module then I get an iteration history from NLPQN that very closely matches the NLMIXED output. There are other issues, the code you posted generates errors in the log, but these are related to some lines of code following the 'close' statement that can be deleted from the program.

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I think the main problem is that you have missed out the factor of 2 pi in the log-likelihood function. If I substitute:

f = - n # log(2 # constant('pi') # sigma2) /2 - ssq(c) / (2 # sigma2);

in the LogLik module then I get an iteration history from NLPQN that very closely matches the NLMIXED output. There are other issues, the code you posted generates errors in the log, but these are related to some lines of code following the 'close' statement that can be deleted from the program.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Amazing, thanks, I didn't notice that! I will have a look after my breakfast thanks so much x

Update- just ran it- perfect! Really grateful, thank you

Update again.... results were slighly different... added update=DBFGS ; to my NLMIXED statement and it's now identical. Two days wasted on this! So glad to see matching numbers!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

This is a common problem. Different software programs sometimes uses different forms of the ML function (usually some variation of the log-likelihood) to optimize. You can drop constants and multiplicative factors without changing the solution. For example, if LL is the log-likelihood function, then -2*LL, -LL, and -2*LL+const all give the same solutions, but report different values for the "Value of the objective function."

For that matter, we use the log-likelihood because it gives the same solution as optimizing the liklihood function, but is more stable numerically.

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.