Statalist The Stata Listserver


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

Re: st: Re: RE: Fw: regarding stata MLE


From   Deepankar Basu <basu.15@osu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: RE: Fw: regarding stata MLE
Date   Thu, 15 Jun 2006 10:33:38 -0400

Suddhasil,

One problem that I see is that you have not specified an equation for
theta2 in your ml model command. You need to do that.

Second, when you run your program many times, you might encounter
problems if you do not use -capture program drop-; you need to add that
in the beginning of the program when debugging. 

Third, since you are estimating the coefficients of a simple regression,
you might use the -normden- command in your likelihood evaluator. Your
likelihood functions seems to have missed the normal density altogether.
Here is what your lf program might be:

clear
capture program drop myprog
program define myprog
version 8.1 /* I assume you are using version 8.1 */
   args lnf theta1 theta2
   quietly replace 'lnf'= ln(normden($ML_y1, `theta1', `theta2'))
end

Then you can do the following from the command line:

.ml model lf myprog (reg: name of dependent variable = name of
independent variables) () /* The second bracket is for theta2 which will
give an estimate of the error variance. */

.ml check /* This will check your program for possible errors; if it
shows that your program has passed all tests, then go ahead and do the
next step. */

.ml max

Now, you should get the results. 

HTH,

Deepankar Basu

 


On Thu, 2006-06-15 at 16:59 +0530, Suddhasil Siddhanta wrote:
> Dear Nick,
> 
> I am now facing a problem in getting results for ml estimation in
> stata.
> 
> the program that I have writen in a lf file is:-
> 
> program define myprog
> 
> args lnf theta1 theta2
> 
> quietly replace 
> 'lnf'= -.5*ln(2*_pi)-.5*ln('theta2')-.5*(($ML_y1-'theta1')^2)/'theta2'
> 
> end
> 
> the statistical details that I have used to form the program is
> 1. the dependent vriable is normally distributed
> the log likelihood is
> 
> ]
> 
> 
> then in the command window I typed
> 
> . ml model lf myprog (reg: name of dependent variable = name of independent
> variables)
> 
> . ml maximize
> 
> now i am getting the eror 198 invalid name
> 
> please suggest me what i am doing wrong
> 
> 
> 
> Best,
> 
> 
> suddhasil
> 
> 
> 
> ----- Original Message ----- 
> From: "Nick Cox" <n.j.cox@durham.ac.uk>
> To: <statalist@hsphsun2.harvard.edu>
> Sent: Thursday, June 08, 2006 6:29 PM
> Subject: st: RE: Fw: regarding stata MLE
> 
> 
> > This is already programmed for you as -regress-.
> >
> > Nick
> > n.j.cox@durham.ac.uk
> >
> > N.B. Please do not send HTML to the list.
> >
> > Suddhasil Siddhanta
> >
> > I've just begun with the maximum likelihood with Stata.
> >
> > Can you please help me in this regard. My estimation equation is a linear
> > one with normal distribution.
> >
> > Y = constant + ax1 +b x2, where y is the dependent variable, a, b are the
> > coefficient and x1, x2 are the independent variables.
> >
> > Can you please help me in providing a programme that will run for the
> > equation.
> >
> > *
> > *   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/



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