Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to fetch VCE


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: How to fetch VCE
Date   Wed, 7 Aug 2002 17:25:49 +0100

James Ferng

I ran the following regression :

By code: regress x y z;

How can I fetch and save the variance-covariance of estimates for each
code
I ran. The stata command "matrix cv=get(VCE) \svmat cv" only gives the
VCE
of last one.

>>> One way resembles an answer given to another question earlier
today.

For simplicity, I'll imagine that the levels of code are
smallish integers or simple strings which can be part
of matrix names. (If not, map them to integers using -egen, group-.)

1. Get -levels- from SSC, then

levels code, local(levels)

2.

qui foreach l of local levels {
	regress x y z if code == `l'
	matrix cv`l' = get(VCE)
}

You should get a series of matrices, perhaps called

cv1, cv2, ...

Note that -levels- is not mandatory here. It is just
a general way of picking up the levels of a categorical
or classifying variable.  But the
idea of looping over the distinct levels of a
categorical variable with -foreach- is very
general and powerful.

For more, see Stata Journal 2(2), 202-222 (2002),
or (for the slide show version)
http://fmwww.bc.edu/RePEc/usug2002/fortitude.pdf


Nick
n.j.cox@durham.ac.uk

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index