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

From |
Maarten buis <maartenbuis@yahoo.co.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Multinomial logit-type probability in log likelihood for ML model |

Date |
Tue, 4 Sep 2007 14:18:32 +0100 (BST) |

Three remarks: 1) I don't entirely understand what you want to do, but it sounds like some sort of mixture model. Maybe the likelihood becomes more tractable if you formulate it as such. 2) If I understand you correctly you want to sum over observations within the likelihood function. That does not sound right to me. -ml- will do the summing for you. 3a) If you really want to sum over observations than a can be stored as a scalar, as it will be constant over observations. Storing a single number _N times is a waste of time and space. 3b) Also I would use the -tempname- command to ensure you don't leave it hanging around after it has finished. 3c) Finally I would not call it a but denom (for denominator). Such names will greatly improve the readablility of your code. (You will be really really grateful when you have to debug your program 6 months from now...) Hope this helps, Maarten --- Bob Hammond <robert.g.hammond@vanderbilt.edu> wrote: > Hey Maarten, > > Thanks for your reply. The objective in the example you sent is to > estimate a multinomial logit (MNL) model, but my objective is > different. I want to estimate a binary choice model where the > probability of Y=1 is governed by a log likelihood function that > contains a MNL-type probability. I can't simply use a MNL model > because > I do not observe the outcome of the MN process. If the MN process is > > described by Binomial(n, j, q), then I observe n, but not j, > preventing > me from using Stata's built-in MNL. My simplification of the log > likelihood function made this less clear than it should have been; > sorry > for the confusion. My approach is to model q as a function of > observed > covariates, allowing me to use the distribution of the unknown j. > > After working more on this, I wonder if I can use the following > (maintaining my simplification from the initial email that ignores > the > fact that j is unobserved): > > gen a = . > ... > egen double `tempvar1' = sum(exp(`theta')) > replace a = 1 + `tempvar1' > replace `lnf' = (Binomial(n,j,exp(`theta')/a) /// > - Binomial(n,j+1,exp(`theta')/a) * f(x) if $ML_y1 == 1 > > That is, can I simply sum up the `theta' for the entire data set into > a > new variable, then use this variable in the "replace `lnf'" > statement? > Thanks, > > Bob > > I posted a -ml- program that does a multinomial logit on statalist > some > > time ago: > > http://www.stata.com/statalist/archive/2007-05/msg00449.html > > > > Hope this helps, > > Maarten > > > > > > --- Bob Hammond <robert.g.hammond@vanderbilt.edu> wrote: > > > > > All, > > > > > > I am having trouble coding an ML program for my log likelihood > > > function. I'll simplify several aspects of the log likelihood > that > > > seem > > > unrelated to my question. Define `lnf' for an individual > observation > > > as > > > follows: > > > > > > replace `lnf' = (Binomial(n,j,q) - Binomial(n,j+1,q)) * f(x) if > > > $ML_y1 == 1 > > > > > > In words, the probability that Y is 1 is the probability of > observing > > > > > > exactly j successes out of n (where q is the probability of a > success > > > on > > > an individual trial) times some function f(x). The probability q > > > takes > > > a multinomial logit form: > > > > > > q_i = exp(X_i * `theta') / (1 + sum(exp(X_h * `theta'))) > > > > > > where the sum goes from h=1, ..., J, so it sums the product of > the > > > covariate vector X times the parameter vector `theta' for all > > > observations in the data set. > > > > > > It seems that I need some way to construct the summation in the > > > denominator of q first, but my confusion is that this denominator > > > contains the `theta' parameter vector. Basically, for every > > > observation > > > in the data set, I need to construct a scalar that multiplies the > 1 x > > > k > > > covariate vector X by the k x 1 parameter vector `theta' that > needs > > > to > > > be estimated. Then I need to sum these J scalars up (call this > a, > > > which > > > is a function of `theta'). If I could do that, then, after > > > constructing > > > a, I would write: > > > > > > replace `lnf' = (Binomial(n,j, exp(`theta') / (1 + a) - > Binomial(n,j, > > > > > > exp(`theta') / (1 + a)) * f(x) > > > if $ML_y1 == 1 > > > > > > I don't know how to construct "a" because it contains the > parameter > > > vector `theta'. I've tried taking a look at the ado file for > mlogit, > > > > > > but didn't find the answer. Thanks in advance, > > > > > > Bob > > -- > ------------------------------------------------------------------------ > Bob Hammond > Department of Economics > Vanderbilt University > http://people.vanderbilt.edu/~robert.g.hammond/ > * > * 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! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.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/

**References**:**Re: st: Multinomial logit-type probability in log likelihood forML model***From:*Bob Hammond <robert.g.hammond@vanderbilt.edu>

- Prev by Date:
**st: P-value** - Next by Date:
**Re: st: xtlogit vs. gllamm. large condition numbers and group variances:what do they mean?** - Previous by thread:
**Re: st: Multinomial logit-type probability in log likelihood forML model** - Index(es):

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