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 |
Maarten Buis <maartenlbuis@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Qreg on Multiple Iterations of Data |

Date |
Mon, 28 Oct 2013 09:54:30 +0100 |

On Sun, Oct 27, 2013 at 10:03 PM, cerulean 74 wrote: > I'd like to use quantile regression for 1000 iterations on 100 > observations: my data consists of values for three variables: Y, X1, > and X0(just a column vector of 1's). Each variable has 1000 columns of > values (each column is an iteration) and 100 rows(each row is an > observation). The goal is to use qreg to obtain 1000 coefficients of > X1, and 1000 coefficients of X0, output to Excel as two column vectors > of coefficients. That is, I would like to regress each column of Y on > the corresponding column of X and X0, a thousand times. I've tried > both STATA and MATA: my version of STATA has a maximum matrix size of > 800, whereas my overall dataset size is 100 by 2001, and MATA does not > have a qreg option. Any advice/tips on how to achieve this? Thanks! Please sign your post to Statalist with your real name. Other forums have different standards, but this is the standard used on this forum as you could and should have read on the Statalist FAQ: http://www.stata.com/support/faqs/resources/statalist-faq/#tojoin Also, there are no such things as STATA or MATA. However, Stata and Mata do exist, so I assumed you mean those programs. See the Statalist FAQ for an explanation: http://www.stata.com/support/faqs/resources/statalist-faq/#spell You can ignore X0, as Stata will by default already include a constant. You can use the -post- command to store the results, which will have no problem with a thousand iterations. *------------------ begin example ------------------ // create some example data drop _all set obs 100 forvalues i = 1/10 { gen x`i' = rnormal() gen y`i' = 1 + 2*x`i' + rnormal(0,.5) } // estimate the -qreg-s and store the results tempname memhold tempfile results postfile `memhold' b1 b0 using `results' forvalues i = 1/10 { qreg y`i' x`i' post `memhold' (_b[x`i']) (_b[_cons]) } postclose `memhold' use `results', clear list *------------------- end example ------------------- * (For more on examples I sent to the Statalist see: * http://www.maartenbuis.nl/example_faq ) However I will presume your thousand iterations are the results of a simulation. In that case it is more efficient to do this differently: *------------------ begin example ------------------ clear all program define sim drop _all set obs 100 gen x = rnormal() gen y = 1 + 2*x + rnormal(0,.5) qreg y x end simulate _b, reps(10) : sim list *------------------- end example ------------------- * (For more on examples I sent to the Statalist see: * http://www.maartenbuis.nl/example_faq ) Hope this helps, Maarten --------------------------------- Maarten L. Buis WZB Reichpietschufer 50 10785 Berlin Germany http://www.maartenbuis.nl --------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Qreg on Multiple Iterations of Data***From:*cerulean 74 <cerulean74@gmail.com>

- Prev by Date:
**SV: st: ROC-curves** - Next by Date:
**st: -hcavar- "too many leaves"** - Previous by thread:
**st: Qreg on Multiple Iterations of Data** - Next by thread:
**st: How to write filename** - Index(es):