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: How to compose constraint with a series of variables?
From
Jorge Eduardo Pérez Pérez <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: How to compose constraint with a series of variables?
Date
Sat, 19 Mar 2011 19:50:17 -0400
Or you could loop over the varlist defined by the phrase, as in the
following example (this has to be run all at once) :
clear
set obs 1000
gen y=uniform()
forvalues i=1(1)50 {
gen phrase`i'=uniform()
gen x`i'=uniform()
}
local i=1
foreach x of varlist phrase* {
constraint define `i' [`x']=1
local i=`i'+1
}
local j=`i'-1
cnsreg y phrase* x*, constraints(1/`j')
Hope this helps,
_______________________
Jorge Eduardo Pérez Pérez
On Sat, Mar 19, 2011 at 5:56 PM, Muyang Zhang <[email protected]> wrote:
> Dear guys,
>
> I wish to set constraints in regression. I know usually it can be
> implemented by the -constraint- command.
>
> But my problem is that I have a series of variables (over 1000)
> starting with the same phrase followed by numbers. How can I compose
> constraints with -*- operator?
>
> Best,
>
> --
> Zhang Muyang
> China Center for Economic Research
> Peking University
> Beijing, 100871
> China.
> *
> * 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/
>
*
* 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/