Statalist The Stata Listserver

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

st: RE: Parameter restrictions in MLE

From   "Maarten Buis" <>
To   <>
Subject   st: RE: Parameter restrictions in MLE
Date   Fri, 26 May 2006 09:49:56 +0200

--- Deepankar Basu wrote:
> I am trying to do a maximum likelihood estimation where some of the
> parameters of the model are probabilities; hence they should add up to
> unity.
> What is the best way to put restrictions on the relevant parameters and
> constrain them to add up to unity?

Deepankar Basu:
Constraints like these are achieved by transformations, for instance: a
variance is always positive. So when estimating a variance we want to 
impose the constraint that it is positive. This is achieved by not 
estimating the variance, but the natural logarithm of the variance, which
can be any positive or negative number. Similarly, a common transformation
that ensures a number remains between 0 and 1 is the logit transformation.
The multivariate extension for that would be the multinomial logit 
transformation. So if you have three probabilities, the relevant part of 
your code would look like:

program whatever_lf
	args lnf mlp2 mlp3 ...
	tempvar p1 p2 p3
	gen double `p1' = 1/(1+exp(`mlp2')+exp(`mlp3'))
	gen double `p2' = exp(`mlp2')/(1+exp(`mlp2')+exp(`mlp3'))
	gen double `p3' = exp(`mlp3')/(1+exp(`mlp2')+exp(`mlp3'))
	very smart likelihood function which uses `p1', `p2', and `p3'

Something similar was done in the -dirifit- command, though the code may
be a bit difficult to read since the number of probabilities was not 
fixed in advance.


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

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z214 

+31 20 5986715

*   For searches and help try:

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