Page 1 of 1

### predict probability and CI

Posted: Wed Nov 28, 2018 6:19 pm
Hi,

I find runmlwin is not compatible with command "margins".
So, I fit a multinominal model and then calculate probabilities by hand using the expression like:
"Pr(y = 1) = " exp([FP1]cons_1)/ ///
(1 + exp([FP1]cons_1) + exp([FP2]cons_2) + exp([FP3]cons_3))"
But I am not sure the correct way to calculate 95% CI of the predicted probability. Does anyone know this? Thank you!

Best wishes,

Rodrigo

### Re: predict probability and CI

Posted: Thu Nov 29, 2018 11:41 am
Hi Rodrigo,

That is correct runmlwin is not comaptabile with margins.

However, you should be able to do what you want simply by using the nlcom command to calculate the expression you have written out.

Best wishes

George

### Re: predict probability and CI

Posted: Thu Nov 29, 2018 12:44 pm
Hi George,

Thank you for your kind reply. I have calculated the probabilities for each response of the multinominal model by hand. But I need 95% CI of prediction, and hence have to calculate standard error of prediction by hand as well (I am not sure the stata command predict se, stdp can work in this circumstance). I didn't find such examples in MLwin User Manual. Could you give me advice how to get standard error of prediction of the multinominal model?

Thanks

Rodrigo

### Re: predict probability and CI

Posted: Thu Nov 29, 2018 3:02 pm
Hi George,

I just manage to get s.e. just by copying or replacing original vars with a set of vars_1 and vars_2 which the stata recognises. The commands are like these (response 0: reference; response 1: oc; response 2: ic):

Code: Select all

``````predict ocxb, outcome(FP1) xb
predict ocse, outcome(FP1) stdp
predict icxb, outcome(FP2) xb
predict icse, outcome(FP2) stdp``````
The predicted ocxb and icxb are exactly the same as I calculated by hand. The two probabilities are thus calculated like

Code: Select all

``````gen prob_oc = exp(ocxb)/(1+exp(ocxb)+exp(icxb))
gen prob_ic = exp(icxb)/(1+exp(ocxb)+exp(icxb))``````
I can also calculate lower and upper bounds of linear prediction

Code: Select all

``````gen oclb = ocxb - 1.96*ocse
gen ocub = ocxb + 1.96*ocse
gen iclb = icxb - 1.96*icse
gen icub = icxb + 1.96*icse``````
So far so good. However, I don't know if calculating CIs is as straightforward as probabilities, because it involves lower and upper bounds of both oc and ic. I

Are the following expressions for calculating lower and upper bounds of the probabilities of oc correct?

Code: Select all

``````gen oclbp = exp(oclb)/(1+exp(oclb)+exp(iclb))
gen ocubp = exp(ocub)/(1+exp(ocub)+exp(icub))``````
Thank you

Rodrigo