SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
timothy19
Fluorite | Level 6

Hello Community,

 

I am trying to calculate model fit for a full and reduced model with the code below using the loglikelihood ratio generated from Proc glimx.

%let numParmsFull = 4;
%let numParmsReduced = 3;
%let LLfull = 4206.91
%let LLreduced = 4088.56
data _null_; set FitStatistics; if Model='Full' then call symput('LLfull',value); if Model='Reduced' then call symput('LLreduced',value); run;
data _null_; df=&numParmsFull-&numParmsReduced; /* numParmsFull and numParmsReduced should be the number of parameters in the full and reduced models respectively */ testStat = &LLfull - &LLreduced; pvalue = 1 - probchisq(testStat,df); run;

When i run the code i get this  ERROR  The function PROBCHISQ is unknown, or cannot be accessed.

Also, can you also help to determine model fit for two model using other method?

Can anyone help with how i can get the p-value.

 

Thanks,

Timothy

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

The function that computes the probability from a chi-square distribution is called PROBCHI, so use

pvalue = 1 - probchi(testStat,df);

In general, I avoid the PROB* functions and use the CDF function instead. So I would use 

pvalue = 1 - cdf("chisq", testStat, df);

or you could use the SDF (survival) function, which has the computation "1 minus CDF" built in:

pvalue = sdf("chisq", testStat, df);

 

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

The function that computes the probability from a chi-square distribution is called PROBCHI, so use

pvalue = 1 - probchi(testStat,df);

In general, I avoid the PROB* functions and use the CDF function instead. So I would use 

pvalue = 1 - cdf("chisq", testStat, df);

or you could use the SDF (survival) function, which has the computation "1 minus CDF" built in:

pvalue = sdf("chisq", testStat, df);

 

timothy19
Fluorite | Level 6

Thank you

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 700 views
  • 3 likes
  • 2 in conversation