Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Estimating linear regression model by maximum likelihood


From   Nilam Prasai <[email protected]>
To   Fernando Rios Avila <[email protected]>, [email protected]
Subject   Re: st: Estimating linear regression model by maximum likelihood
Date   Thu, 10 Mar 2011 15:18:19 -0500

Dear Fernando
Thank you very much.
Actually I am learning stata. I am not familiar with ML function in
stata. Your program helped me a lot. But I don't understand what you
mean by "the parameters a1, a2 , a3 need to be transformed before
u obtained the estimates of the model". Can you please clarify here?
Your program has immensely helped me out. I am learning and doing how
all those stops exactly implement in stata.
I appreciate it.
Nilam


On Thu, Mar 10, 2011 at 1:48 PM, Fernando Rios Avila <[email protected]> wrote:
> Hi Nilam
> First of all, i should say you have to start by running your model without
> any constrain to see if the data doesnt reject your constrains.
> If your constrains are not rejected, you could just program the ML function
> in stata. Im assuming u are familiar with the ML in stata, so i ll just
> write the code:
>
> program define MLlinear
> args lnf a1 a2 a3 sigma
> tempvar y x1 x2 x3 error
> tempvar b1 b2 b3 error
> gen double `y'  =$ML_y1
> gen double `x1'=$ML_y2
> gen double `x2'=$ML_y3
> gen double `x3'=$ML_y4
>
> now to be sure your constrains are imposed
> gen double `b1'=exp(`a1')/(1+exp(`a1'))
> and for the rest just functions of the first one
> gen double `b2'=exp(`a2')/(1+exp(`a2'))*(1-`b1')
> gen double `b3'=exp(`a3')/(1+exp(`a3'))*(1-`b1'-`b2')
> gen double `error'=`y'-`b1'*`x1'-`b2'*`x2'-`b3'*`x3'
> replace `lnf'=log(normalden(`error',`sigma')
> end
> after this, and afterthe program is called
> ml model lf MLlinear (a1:y x1 x2 x3=) (a2:) (a3:) (sigma:), maximize
> just remember that the parameters a1, a2 , a3 need to be transformed before
> u obtaine your estimates of the model.
> Good luck
>
> On Thu, Mar 10, 2011 at 1:06 PM, Fernando Rios Avila
> <[email protected]> wrote:
>>
>>
>> ---------- Forwarded message ----------
>> From: Nilam Prasai <[email protected]>
>> To: [email protected]
>> Date: Thu, 10 Mar 2011 13:04:29 -0500
>> Subject: st: Estimating linear regression model by maximum likelihood
>> Dear Stata Users,
>> I am trying to estimate a linera regression by maximum likelihood
>> while imposing the constraints.
>> I am trying to regress GDP/capita on three independent variables while
>> imposing the constraint on parameter estimates.
>> The constraint on my coefficeint estimate/parameter efficient will be
>> that: non of the coefficient estimate should be negative and the sum
>> of the coefficients for all the three variable should not be greater
>> than 1 meaning that they should lie between zero to one while their
>> sum (sum of three variables) should not be more than 1.
>>
>> Please help me out how can I do this in Stata.
>> Nilam Prasai
>>
>> *
>> *   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/
>> Content-Type: text/plain; charset=US-ASCII
>> Content-Transfer-Encoding: quoted-printable
>> Content-Disposition: inline
>>
>> Dear Stata Users,
>> I am trying to estimate a linera regression by maximum likelihood
>> while imposing the constraints.
>> I am trying to regress GDP/capita on three independent variables while
>> imposing the constraint on parameter estimates.
>> The constraint on my coefficeint estimate/parameter efficient will be
>> that: non of the coefficient estimate should be negative and the sum
>> of the coefficients for all the three variable should not be greater
>> than 1 meaning that they should lie between zero to one while their
>> sum (sum of three variables) should not be more than 1.
>>
>> Please help me out how can I do this in Stata.
>> Nilam Prasai
>>
>> *
>> *   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/
>>
>>
>
>



-- 
Nilam Prasai

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index