Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: multilevel ordered logit cond prob in gllapred


From   Michael Ingre <Michael.Ingre@ipm.ki.se>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: multilevel ordered logit cond prob in gllapred
Date   Thu, 24 Mar 2005 12:57:29 +0100

I did something similar a while ago using -nlcom- on an estimated ordered ologit with -gllamm-. An example of how I did it is presented below using auto.dta.

// Michael

clear
sysuse auto

// Create level 2 ID
gen make2 = substr(make, 1, index(make, " "))
egen pick =tag(make2)
gen id=_n if pick
sort make2 id
replace id = id[_n-1] if id == .

// Make turn>40 a dichotomous predictor variable
gen turn40 = turn > 40

// estimate gllamm model on rep78 with turn40 as predictor
gllamm rep78 turn40 , i(id) link(ologit) fam(bin) adapt

// Use local macros to temporary hold your input values
local pv1 = 1 // predictor value 1
local pv2 = 0 // predictor value 2
local cut = 11 // Choose cut point i.e. which level of the dependent variable you want to predict

// calculate log of the ratio of the two probabilities predicted from pv1/pv2
nlcom ln( (exp(`pv1' * [rep78]turn40 - [_cut`cut']_cons) / ///
(1 + exp(`pv1' * [rep78]turn40 - [_cut`cut']_cons))) / ///
(exp(`pv2' * [rep78]turn40 - [_cut`cut']_cons) / ///
(1 + exp(`pv2' * [rep78]turn40 - [_cut`cut']_cons))))

// Store the results from -nlcom-
matrix b = r(b)
matrix V = r(V)

// Values needs to be exponentiated to describe RRR
di "RRR: " exp(b[1,1])
di "Lower 95% CI " exp(b[1,1] - sqrt(V[1,1])*1.96)
di "Upper 95% CI " exp(b[1,1] + sqrt(V[1,1])*1.96)



On 2005-03-23, at 20:49, INAGAMI,SANAE wrote:


I have looked at the gllamm manual. I just don't know how to write the
commands.

I want to know the probability of each ordered outcome conditional on a
categorical predictor variable being 1.

Then with the same command, I want to change the predictor variable to 0.

Then I would like to set up a relative risk of outcomes by creating a
ratio of the probabilities (1 vs 0).

Then I would like to come up with confidence intervals for those ratios.

I can do this in ordered logistic stata, but I can't do it with glamm
because I think I set up the syntax incorrectly.

Thanks.
Sanae
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/


------------------------------------------------
Michael Ingre , PhD student & Research Associate
Department of Psychology, Stockholm University &
National Institute for Psychosocial Medicine IPM
Box 230, 171 77 Stockholm, Sweden

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index