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]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: RE: Looping with -qreg- |

Date |
Thu, 19 Jan 2012 13:59:19 +0000 |

Nick

Thanks Nick for your comments.I did try with constraint option but didn't get what I need.Basically my problem is to estimate the last qreg with the newconstant term (u99) 'plug' in the model. There is not nonconsoption in qreg.Best wishes Anita ________________________________________From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] on behalf of Nick Cox[njcoxstata@gmail.com]Sent: 19 January 2012 11:52 To: statalist@hsphsun2.harvard.eduSubject: Re: Looping with -qreg- [was: Re: st: Thread-Index:AczWnG9bfd8mYxtIRa2sdn3BOpo1xA==]Also, it sounds as if you want to constrain your -qreg-, which makes me feel queasy even contemplating the idea from a distance, but if so that implies trying -constraint-. NickOn Thu, Jan 19, 2012 at 11:45 AM, Nick Cox <njcoxstata@gmail.com>wrote:Please use informative titles (subjects) for your postings. Many people delete posts unread if they have weird titles. There are problems at various levels with your code. 1. The line local `b' = scalar(u99) looks like a mistake. If local b _was_ previously defined, then you need to refer to what this line defines as ``b''.2. But you don't refer either to `b' or to ``b'' after defining it,soall you have done is defined something but never used it. 3. If local b was not previously defined, this line would not work. But that is not what you are reporting, so my guess is that a "local b" is defined earlier in your code. 4. If you have a scalar, there is no obvious need to put it into a local for what you want to do. 5. I don't understand what you want to do, but you are changing results, not instructions. Later runs of -qreg- pay no attention to e(b) produced by earlier runs of -qreg-. 6. -matrix b- and -local b- are completely different entities. Nick On Thu, Jan 19, 2012 at 11:21 AM, STANEVA A. (497186) <A.V.STANEVA.497186@swansea.ac.uk> wrote:Can someone help me with this loop in a qreg? This first line works ok! forval i = 1/99 { local q = `i'/100 quietly qreg $y $x if public==0, quantile(`q') nolog matrix b = e(b)matrix b[1, colnumb(b,"_cons")] = scalar(u99) /*I get the constantand replace it with the scalar u99, that I want/}The problem comes here. I want the replaced u99 to be included inmy qreg and then to get the predictions based on that regression:forval i = 1/99 { local q = `i'/100 local `b’= scalar (u99) quietly qreg $y $x if public==0, quantile (`q') nolog predict xb if public==0 preserve keep if xb~=. restore }However, there is a problem in the line local`b'=scalar(u99), itseems stata doesn’t replace the _cons with the u99. It runs normal qreg, ignoring all this manipulations.

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

**Follow-Ups**:**RE: st: RE: Looping with -qreg-***From:*"STANEVA A. (497186)" <A.V.STANEVA.497186@swansea.ac.uk>

**References**:**st: RE: Looping with -qreg-***From:*"STANEVA A. (497186)" <A.V.STANEVA.497186@swansea.ac.uk>

- Prev by Date:
**Re: st: Stata equivalent of SAS code** - Next by Date:
**st: Treatreg in the Svy context: no test for rho?** - Previous by thread:
**st: RE: Looping with -qreg-** - Next by thread:
**RE: st: RE: Looping with -qreg-** - Index(es):