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 linear regression... is not linear?
From
Austin Nichols <[email protected]>
To
[email protected]
Subject
Re: st: Constrained linear regression... is not linear?
Date
Tue, 7 Dec 2010 11:14:30 -0500
If you're getting an answer outside [0,1] then perhaps your model is
incorrectly specified, and you should rethink it. That said, try:
drawnorm x z e, n(1000) clear seed(1)
g y=min(max(1,round(3+.3*x+.7*z+e)),5)
g ylz=y-z
constraint define 1 x+z = 1
cnsreg y x z, c(1-3)
nl (y={a}+{b}*x+(1-{b})*z)
loc i=logit(.3)
qui nl (y={a=0}+invlogit({b=`i'})*x+(1-invlogit({b=`i'}))*z)
nlcom (invlogit([b]_cons)) (1-invlogit([b]_cons))
qui nl (ylz={a=0}+invlogit({b=`i'})*(x-z))
nlcom (invlogit([b]_cons)) (1-invlogit([b]_cons)), post
test _b[_nl_1]=_b[_nl_2]
On Tue, Dec 7, 2010 at 3:06 AM, Maarten buis <[email protected]> wrote:
> --- On Tue, 7/12/10, kokootchke wrote:
>> I am trying to run the following constrained linear
>> regression:
>> y = ax + (1-a)z, with a in [0,1]
> <snip>
>> What I'm doing is the following:
>> constraint define 1 x+z = 1
>> constraint define 2 x >= 0
>> constraint define 3 x <= 1
>> cnsreg y x z, c(1-3)
>
> Constraints 2 and 3 are not allowed with -cnsreg-. The
> problem is the fact that you want to constrain the parameter
> within a certain range, and this is not considered to be
> linear constraint. If you want to estimate this model you'll
> have to use either -nl- or -ml- as is discussed here:
> <http://www.stata.com/support/faqs/stat/intconst.html>
*
* 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/