You could also use -estadd vif- (which is part of the -estout-
package, see -ssc d estout-):
forv i=1/10 {
qui reg invest mvalue kstock time if company == `i'
estadd vif
est sto company`i'
}
estout company* using myvifs.txt, cells(vif)
ben
On Sun, Apr 20, 2008 at 5:40 PM, Nuno <[email protected]> wrote:
> Just a minor clarification to the previous code:
>
>
> webuse grunfeld,clear
> mat vif = J(10,3,.)
> mat colnames vif = "mvalue kstock time"
>
>
> forv i=1/10 {
> qui reg invest mvalue kstock time if company == `i'
> vif
> forv j=1/3 {
> mat vif[`i', colnumb(vif,r(name_`j'))] = r(vif_`j')
>
> }
> }
> mat list vif
> // mat2txt from ssc
> mat2txt, mat(vif) saving(myvifs) format(%9.3f) replace type myvifs.txt
>
>
> For some reason (at least in my code), the identifier of each variable was
> changing in some of iteractions. This meant that, I could have started with
> mvalue vif at the first iteraction and on the next iteraction I could have
> kstock vif in the same column. This way the code names the columns and
> searches the correct column to input the corresponding vif.
>
> Best,
>
> Nuno
>
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Kit Baum
> Sent: 19 April 2008 23:12
> To: [email protected]
> Subject: st: re: how to save VIF measure in a file
>
>
> This should work for you:
>
> > webuse grunfeld,clear
> > mat vif = J(10,3,.)
> > forv i=1/10 {
> > qui reg invest mvalue kstock time if company == `i'
> > vif
> > forv j=1/3 {
> > mat vif[`i', `j'] = r(vif_`j')
> > }
> > }
> > mat list vif
> > // mat2txt from ssc
> > mat2txt, mat(vif) saving(myvifs) format(%9.3f) replace type myvifs.txt
>
>
>
> Kit Baum, Boston College Economics and DIW Berlin
> http://ideas.repec.org/e/pba1.html
> An Introduction to Modern Econometrics Using Stata:
> http://www.stata-press.com/books/imeus.html
>
>
> *
> * 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/
>
> *
> * 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/
>
*
* 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/