predict probability and CI

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to runmlwin: Running MLwiN from within Stata >> http://www.bristol.ac.uk/cmm/software/runmlwin/
Post Reply
rodrigowu
Posts: 8
Joined: Wed Mar 15, 2017 4:57 pm

predict probability and CI

Post by rodrigowu »

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
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: predict probability and CI

Post by GeorgeLeckie »

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
rodrigowu
Posts: 8
Joined: Wed Mar 15, 2017 4:57 pm

Re: predict probability and CI

Post by rodrigowu »

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
rodrigowu
Posts: 8
Joined: Wed Mar 15, 2017 4:57 pm

Re: predict probability and CI

Post by rodrigowu »

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
Post Reply