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!
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;
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;
@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?
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.