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
Determine how many respondents answered a question where they could select multiple responsesI am no STATA guru, so this may be simple, but I cannot find guidance anywhere (probably because I d…
count number of unique values over a rolling time window defined by a date variableDear Stata community, I'd like to generate a variable that records the number of unique values of a…
To generate a new variable to subset a dataset based off number of visit a patient has attendedDear all, Patient number is a key identifier variable. For example Patients have come for 3 visits,…
Heckprobit regression with dummy variablesI have done a heckprobit regression on a cross section data. My main explanatory variable is a distr…
getting error doing structural testHello all, I am testing for structural breaks using estat sbsingle. I am specifically focusing on th…
Subscribe to:
Post Comments (Atom)
0 Response to Melogit Random Effect Prediction
Post a Comment