Hi everyone,
I'm trying to understand the random effect predictions of multilevel logistic regression in Stata 14. I'm trying to describe the variation of pneumonia in stroke patients nested within stroke units. So I ran 2 different melogit models, the first one being just the outcome and the random intercept of the stroke unit and then the adjusted model including all the predictors involved with the development of pneumonia.
When I run predict the random effects, a number of stroke units report a value of 0. So when I graph the predicted probabilities for each stroke unit, I can see a space between stroke units 100-130 that have the same values.
Could someone help me understand why do these stroke units report this?
Here is the syntax and the resulting graphsArray
preserve
drop if strokecount1==.
melogit sap7days_n i.ageonarrival i.s2rankinbeforestroke i.loc nihssonarrivalnew_n gender_n chf_n afib_n diabetes_n htn_n prevstroketia_n dysphagia_n|| stroketeam_n:,or iterate (50)
estimates store m2
drop if e(sample)!=1
predict adjustedre, reffects reses(newadjustedrese)
melogit sap7days_n || stroketeam_n:, or iterate(50)
estimates store m1
predict unadjustedre, reffects reses (unadjustedrese)
keep adjustedre newadjustedrese unadjustedre unadjustedrese stroketeam_n
collapse adjustedre newadjustedrese unadjustedre unadjustedrese, by(stroketeam_n)
list, sep(0)
egen rankmeanunadjusted=rank(unadjustedre), unique
egen rankmeanadjusted=rank(adjustedre), unique
sort rankmeanunadjusted
list, sep(0)
sort rankmeanadjusted
list, sep(0)
gen low1=unadjustedre-1.96*(unadjustedrese)
gen high1=unadjustedre+1.96*(unadjustedrese)
gen low2=adjustedre-1.96*(newadjustedrese)
gen high2=adjustedre+1.96*(newadjustedrese)
gen newadjustedre1 = 1/(1+exp(-1*(adjustedre)))
gen lownewciadjusted = 1/(1+exp(-1*(low2)))
gen uppnewciadjusted = 1/(1+exp(-1*(high2)))
gen newunadjustedre1 = 1/(1+exp(-1*(unadjustedre)))
gen lownewunadjustedci = 1/(1+exp(-1*(low1)))
gen uppnewunadjustedci = 1/(1+exp(-1*(high1)))
summarize newadjustedre1, detail
summarize newunadjustedre1, detail
graph box newunadjustedre1 newadjustedre1
twoway (rcap lownewciadjusted uppnewciadjusted rankmeanadjusted) (scatter newadjustedre1 rankmeanadjusted)
twoway (rcap lownewunadjustedci uppnewunadjustedci rankmeanunadjusted) (scatter newunadjustedre1 rankmeanunadjusted)
lrtest m1 m2
restore
Cheers,
Marco
Related Posts with Melogit Random Effect Prediction
Hausman test after asclogitI need to run a hausman test after running the asclogit command, but i receive the following output …
First differences and lagged variables in panel dataHello everybody, I'm quite new to Stata and I would like to generate first differences of all my va…
Panel Data TechniquesHello, I'm running a fixed effect model (after proven by Hausman Test) and I'm not sure if the code …
melogit vs bayesian melogit I would be appreciated if you could help me. I have conducted a multilevel model for binary outcome…
empty rows removed when importinghello I am importing the attached txt file. The code I used is: Code: import delimited test.txt,…
Subscribe to:
Post Comments (Atom)
0 Response to Melogit Random Effect Prediction
Post a Comment