turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Comparing models based on log-likelihood values

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-19-2017 07:01 AM

Hi,

I would like to compare a number of models based on their log-likelihood values. The log-likelihood values are saved in one dataset as follows:

A difference of 0.01 between two log-likelihood values is considered to be the same model. I would also like to print the % or number of models that were the same and what observation number it was.

Does anyone know if this is possible? Any help with this would be greatly appreciated!

Accepted Solutions

Solution

09-20-2017
03:59 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to aoifeoneill

09-19-2017 12:49 PM

Hi,

I think no need to compare each value with all the ramaining ones. First sort data based log_likelihood values then use the syntax. It will make the comparison easier.

proc sort data=have;

by log_likelihood;

run;

data want;

set have;

diff = log_likelihood - lag(log_likelihood);

if _n_>1 then do;

if abs(diff)<=0.001 then observation=_n_;

end;

run;

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to aoifeoneill

09-19-2017 07:58 AM

Hi,

Something like this?

data want;

set have;

diff = log_likelihood - lag(log_likelihood);

if _n_>1 then do;

if abs(diff)<=0.001 then observation=_n_;

end;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stat_sas

09-19-2017 09:29 AM

@stat_sas to determine the number of models that are the same do you not need to compare likelihood 1 with all other likelihood values, likelihood 2 with all other likelihood values, and so on. Not just the value directly following... maybe I need to loop this?

Solution

09-20-2017
03:59 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to aoifeoneill

09-19-2017 12:49 PM

Hi,

I think no need to compare each value with all the ramaining ones. First sort data based log_likelihood values then use the syntax. It will make the comparison easier.

proc sort data=have;

by log_likelihood;

run;

data want;

set have;

diff = log_likelihood - lag(log_likelihood);

if _n_>1 then do;

if abs(diff)<=0.001 then observation=_n_;

end;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stat_sas

09-20-2017 04:01 AM

Yes of course, thanks @stat_sas !