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: Constrained Regression in Stata
From
Austin Nichols <[email protected]>
To
[email protected]
Subject
Re: st: Constrained Regression in Stata
Date
Fri, 3 Jun 2011 15:54:52 -0400
Whoops--of course they have to be if they are all positive and sum to one.
The manual entry for -nl- mentions the mlogit transform as well...
On Fri, Jun 3, 2011 at 3:53 PM, Austin Nichols <[email protected]> wrote:
> Steve--
> True that (1-exp(_b[/b1])-exp(_b[/b2])) need not be positive, in which
> case another parametrization would be required to meet the poster's
> desiderata (possibly just switching the order of b1, b2, b3 would work
> in many cases); did you mean to constrain all coefs to be less than
> one as well?
>
> On Fri, Jun 3, 2011 at 3:08 PM, Steven Samuels <[email protected]> wrote:
>> In Austin's example, the third coefficient is constrained to be: (1-exp(_b[/b1])-exp(_b[/b2].
>> I don't see that this guarantees that the coefficient will be positive. The following code does, though in this example, the results are identical:
>>
>> ***************************************
>> nl (gpm= (exp({b1})/(1+exp({b1})+exp({b2})))*wt ///
>> + (exp({b2})/(1+exp({b1})+exp({b2})))*l ///
>> + (1/(1+exp({b1})+exp({b2})))*tn ///
>> +{_cons})
>>
>> nlcom (exp(_b[/b1])/(1+exp(_b[/b1])+exp(_b[/b2]))) ///
>> (exp(_b[/b2])/(1+exp(_b[/b1])+exp(_b[/b2]))) ///
>> (1/(1+exp(_b[/b1])+exp(_b[/b2]))), post
>> *****************************************************
>>
>>
>> Steve
>>
>> On Jun 3, 2011, at 10:05 AM, Austin Nichols wrote:
>>
>> If you want to impose all coefs are nonnegative and sum to one, try:
>>
>> sysuse auto, clear
>> g gpm=1/mpg
>> g wt=weight/1000
>> g l=length/1000
>> g tn=turn/1000
>> reg gpm wt l tn, nohe
>> * constrained to be positive:
>> nl (gpm=exp({b1})*wt+exp({b2})*l+exp({b3})*tn+{_cons}), nolog
>> nlcom (exp(_b[/b1])) (exp(_b[/b2])) (exp(_b[/b3])), post
>> * constrained to be positive and sum to one:
>> nl (gpm=exp({b1})*wt+exp({b2})*l+(1-exp({b1})-exp({b2}))*tn+{_cons})
>> nlcom (exp(_b[/b1])) (exp(_b[/b2])) (1-exp(_b[/b1])-exp(_b[/b2])), post
>>
>> But imposing such assumptions tends to result in very implausible
>> models, unless the unconstrained coefs are very close to satisfying
>> your constraints. See also p.1188 of [R] nl.
>>
>> On Fri, Jun 3, 2011 at 2:03 AM, Nick Cox <[email protected]> wrote:
>>> This is an FAQ. See
>>>
>>> How do I fit a regression with interval constraints in Stata?
>>> Isabel Cañette, StataCorp
>>> October 2006; updated July 2008; minor revisions April 2011
>>> http://www.stata.com/support/faqs/stat/intconst.html
>>>
>>> Nick
>>>
>>> On Fri, Jun 3, 2011 at 12:24 AM, Meg22 <[email protected]> wrote:
>>>
>>>> I need to do a constrained regression in stata-I need all the beta
>>>> coefficents to be positive and sum to 1.
>>>>
>>>> I have 11 independent variables so my regression is:
>>>> reg Rrf bills it lt cor lcvalue lcgrowth medcap smallcap noncanbonds us jap
>>>> if fundno ==`i'
>>>>
>>>> I need all the betas to be positive, sum to 1 and there to be a constant.
>
*
* 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/