[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Greg Colman <greg_colman1@yahoo.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: possible bug in ml method lf |

Date |
Tue, 15 Dec 2009 11:39:44 -0800 (PST) |

Dear Listers, The following code creates 5 observations on x, which has a density theta*x^(theta-1). I then estimate theta using Stata's ml routine, first with method lf and then with d0. In each case theta is estimated with and without a constraint, the constraint being that theta = 3. The point of this exercise is to get Stata to calculate the gradient and the variance using formulas for the unconstrained likelihood but at the constrained value of theta, as one would do in a lagrange multiplier test. The formula for the variance of theta is theta^2/n, which for the constrained model is 1.8. This is exactly what is produced by method d0 (and d1, though that's not shown), but quite far from what is produced by method lf. Does this not imply something is wrong with method lf? version 11.0 clear all capture log close set more off set seed 875411 local obs 5 set obs `obs' local theta = 2 gen u = runiform() gen x = exp(ln(u)/`theta') gen lnx = ln(x) sum lnx sca meanlnx = r(mean) sca theta1 = -1/meanlnx sca vartheta1 = theta1^2/`obs' sca list theta1 vartheta1 cap prog drop mlexamp1 prog define mlexamp1 args lnf theta qui replace `lnf' = ln(`theta') + (`theta'-1)*ln($ML_y1) end cap prog drop mlexamp2 prog define mlexamp2 args todo b lnf g tempvar theta mleval `theta' = `b' quietly { mlsum `lnf' = ln(`theta') + (`theta'-1)*ln($ML_y1) } end local null = 3 /* lf version */ ml model lf mlexamp1 (x =) ml maximize ml model lf mlexamp1 (x =) ml init `null', copy ml maximize, iter(0) mat list e(V) /* d0 version */ ml model d0 mlexamp2 (x =) ml maximize ml model d0 mlexamp2 (x =) ml init `null', copy ml maximize, iter(0) mat list e(V) Thanks, Greg * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: help with fractional logit and marginal effects** - Next by Date:
**Re: st: help with fractional logit and marginal effects** - Previous by thread:
**st: help with fractional logit and marginal effects** - Next by thread:
**st: Catplot Bar Patterns** - Index(es):

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