Comparing models based on log-likelihood values

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Comparing models based on log-likelihood values

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:

LogL.PNG

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
Trusted Advisor
Posts: 1,270

Re: Comparing models based on log-likelihood values

Posted in reply to aoifeoneill

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;

View solution in original post


All Replies
Trusted Advisor
Posts: 1,270

Re: Comparing models based on log-likelihood values

Posted in reply to aoifeoneill

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;

Occasional Contributor
Posts: 9

Re: Comparing models based on log-likelihood values

@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
Trusted Advisor
Posts: 1,270

Re: Comparing models based on log-likelihood values

Posted in reply to aoifeoneill

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;

Occasional Contributor
Posts: 9

Re: Comparing models based on log-likelihood values

Yes of course, thanks @stat_sas !
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 377 views
  • 0 likes
  • 2 in conversation