Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Class membership probabiliy and mlogit


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Class membership probabiliy and mlogit
Date   Mon, 14 May 2007 13:03:06 +0100 (BST)

In this case a multinomial variant of the fractional logit would be
applicable. This is not possible with the official Stata �mlogit- or 
�glm- commands. However, it is relatively easy to program such a
command yourself. In the example code below I show such a command for 3
categories. When the data is categorical it should reproduce the
results from �mlogit-, hence the example. In your case you would extend
the program fmlogit_lf to 6 categories, make six globals (e.g. y1-y6)
which contain the variable names of the probabilities, at the end of
the �ml model- statement you add the option ", robust". Some of the
tricks I use in this example are explained in
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html .

*---------------- begin example ----------------
sysuse auto, clear
recode rep78 1/2=3
mlogit rep78 price mpg foreign
 
gen rep3 = rep78==3 if rep78 <.
gen rep4 = rep78==4 if rep78 <.
gen rep5 = rep78==5 if rep78 <.

global y3 "rep3"
global y4 "rep4"
global y5 "rep5"

capture program drop fmlogit_lf
program define fmlogit_lf
     *! 1.0.0 MLB 23 Apr 2007
      version 8.2
      args lnf xb4 xb5 
      tempvar p3 p4 p5

      quietly {
            gen double `p3' = 1/(1+exp(`xb4')+exp(`xb5'))
            gen double `p4' = exp(`xb4')/(1+exp(`xb4')+exp(`xb5'))
            gen double `p5' = exp(`xb5')/(1+exp(`xb4')+exp(`xb5'))
            replace `lnf' = $y3*ln(`p3') + $y4*ln(`p4') + $y5*ln(`p5')
      }
end

ml model lf fmlogit_lf (xb4:rep78 = price mpg foreign) /*
*/ (xb5:price mpg foreign)
ml check
ml search
ml maximize
*-------------- end example ---------------------

Hope this helps,
Maarten



--- "Jon Heron (ALSPAC)" <[email protected]> wrote:
>  Hi Maarten,
> 
> 
>  unfortunately, our data don't appear suitable for this model
>   - all but 3% of the cases have at least one probability which is
>  equal to zero
> 
>  In particular, for the commonest response 'patterns' YYYYYYY and
>  NNNNNNN, we find ourselves with one probability practically equal
>  to one and very little else.  Only when we have a great deal of
>  uncertainly, e.g. for NYNNYNY will we get six non-zero class
> assignment
>  probs.
> 
> 
>  cheers
> 
> 
>  Jon
> --------------------------------------------------
> Dr Jon Heron
> Statistics Team Leader
> ALSPAC, Dept of Social Medicine
> 24 Tyndall Avenue
> Bristol BS8 1TQ
> Tel: 0117 3311616
> Fax: 0117 3311704
> 
> 
> 
> --On 11 May 2007 20:24 +0100 Maarten buis <[email protected]>
> wrote:
> 
> > I have another suggestion. You could use the probabilities as the
> > dependent variable by estimating a -dirifit- model. See:
> > http://home.fsw.vu.nl/m.buis/software/dirifit.html
> >
> > Hope this helps,
> > Maarten
> >
> > --- Jonathan Sterne <[email protected]> wrote:
> >
> >> Dear statalisters
> >>
> >> We have been fitting latent class models, the output of which is a
> >> set of
> >> posterior probabilities that each subject falls into one of six
> >> latent
> >> classes. We now want to use multinomial logistic regression
> (mlogit)
> >> to
> >> examine predictors of class membership.
> >>
> >> One option is to assign each subject to her/his modal class (the
> >> class for
> >> which there is the highest probability of membership. However
> loses
> >> information (some subjects will have a high probability that they
> >> belong to
> >> a particular class, others will have relatively similar
> probabilities
> >> of
> >> membership of two or more classes.
> >>
> >> As an alternative, we wish to fit multinomial logistic regression
> >> models
> >> using the class variable as the multinomial outcome and weighting
> the
> >>
> >> analysis using class membership probabilities.
> >>
> >> We have stacked the data so we have multiple rows for each subject
> in
> >> the
> >> following form
> >>
> >> 	ID     Exposure     Class     Prob
> >>         1      1            1         0.1
> >>         1      1            2         0.1
> >>         1      1            3         0.4
> >>         1      1            4         0.3
> >>         1      1            5         0.05
> >>         1      1            6         0.05
> >>
> >> 'Prob' sums to one within subject and class repeats 1,2,3,4,5,6
> >> through the
> >> whole dataset.
> >>
> >> We weight using pweights [pw = prob]
> >>
> >> Consequently, our model of choice has been:
> >>
> >> xi: mlogit class xvars [pw = prob], rrr
> >> (identical to xi: mlogit class xvars [iw = prob], rrr robust)
> >>
> >> and we have also experimented with
> >>
> >> xi: mlogit class xvars [pw = prob], rrr robust cluster(id)
> >>
> >> which gives lower SE's, and
> >>
> >> xi: mlogit class exposure [iweight = prob], rrr
> >>
> >> which gives *higher* SE's than the pweight model without 'robust'
> >>
> >> We would be grateful for advice on the following questions:
> >>
> >> 1. Is it appropriate to weight according to class membership
> >> probability
> >> (we are pretty convinced that it is)?
> >>
> >> 2. Does anyone have a recommendation as to which of the above
> model
> >> formulations gives theoretically appropriate standard errors?
> >>
> >> Many thanks
> >>
> >> Jonathan Sterne
> >>
> >>
> >>
> >>
> >> *
> >> *   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/
> >>
> >
> >
> > -----------------------------------------
> > Maarten L. Buis
> > Department of Social Research Methodology
> > Vrije Universiteit Amsterdam
> > Boelelaan 1081
> > 1081 HV Amsterdam
> > The Netherlands
> >
> > visiting address:
> > Buitenveldertselaan 3 (Metropolitan), room Z434
> >
> > +31 20 5986715
> >
> > http://home.fsw.vu.nl/m.buis/
> > -----------------------------------------
> >
> >
> > 		
> > ___________________________________________________________
> > Yahoo! Messenger - with free PC-PC calling and photo sharing.
> > http://uk.messenger.yahoo.com *
> > *   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/
> 
> 
> 
> 
> *
> *   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/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________ 
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html 
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index