BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fumikam
Calcite | Level 5

Does anyone know how to calculate the probability based on NLMIXED logit model by plugging in the coefficients or setting it as an average of the whole sample?

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

The way the predicted probability is computed is right there in your NLMIXED code. Plug in the values of your predictors and use the estimated parameter estimates to compute your xb variable, and then transform it as in the next statement to obtain your prob variable which is the predicted probability. But I should note that this is just a simple logistic model and there is no reason to go to the trouble of using NLMIXED ... the model is easily fit in PROC LOGISTIC. The OUTPUT statement does the same as the PREDICT statement. 

 

proc logistic;
model metab3=time sex age;
output out=preds p=pred;
run;

You mentioned wanting to compare high and low risk groups, but I don't see anything like a group variable in your model. If you add a group variable in the model, then you can use the LSMEANS statement in PROC LOGISTIC to display the probabilities for the two groups and get a test comparing them by adding to the above statements as follows:

 

proc logistic;
class group / param=glm;
model metab3=group time sex age;
output out=preds p=pred;
lsmeans group / ilink diff;
run;

View solution in original post

5 REPLIES 5
jiltao
SAS Super FREQ

seems to me that you might need an ESTIMATE statement. Can you provide more information on your PROC NLMIXED program and what you are trying to estimate?

fumikam
Calcite | Level 5
Thank you for your reply. Here is my code.

I'm comparing the High metabolic syndrome risk group and the Low risk group.

I found estimates but want to know the probability of the high risk group.


proc nlmixed data=myfolder.metab;

parms b0=0 b1=0 b2=0 b3=0;

xb = b0 + b1*time + b2*sex + b3*age;

prob = exp(xb)/(1+exp(xb));

liklhd = (prob**metab3)*((1-prob)**(1-metab3));

ll = log(liklhd);

model metab3 ~ general(ll);

run;


StatDave
SAS Super FREQ
Just use the PREDICT statement and specify the name of the variable in your code that is the binomial probability. The PREDICT statement will then provide the predicted probability for each observation in the input data set.
fumikam
Calcite | Level 5
Thank you for your reply. I used a predict statement and found the mean std
but I still need how to calculate probability.
StatDave
SAS Super FREQ

The way the predicted probability is computed is right there in your NLMIXED code. Plug in the values of your predictors and use the estimated parameter estimates to compute your xb variable, and then transform it as in the next statement to obtain your prob variable which is the predicted probability. But I should note that this is just a simple logistic model and there is no reason to go to the trouble of using NLMIXED ... the model is easily fit in PROC LOGISTIC. The OUTPUT statement does the same as the PREDICT statement. 

 

proc logistic;
model metab3=time sex age;
output out=preds p=pred;
run;

You mentioned wanting to compare high and low risk groups, but I don't see anything like a group variable in your model. If you add a group variable in the model, then you can use the LSMEANS statement in PROC LOGISTIC to display the probabilities for the two groups and get a test comparing them by adding to the above statements as follows:

 

proc logistic;
class group / param=glm;
model metab3=group time sex age;
output out=preds p=pred;
lsmeans group / ilink diff;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 641 views
  • 0 likes
  • 3 in conversation