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" <[email protected]>
To   <[email protected]>
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
I ran. The stata command "matrix cv=get(VCE) \svmat cv" only gives the
of last one.

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

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)


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)

[email protected]

*   For searches and help try:

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