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

R�p. : st: Estout and VIF - Correction


From   "Herve STOLOWY" <[email protected]>
To   <[email protected]>
Subject   R�p. : st: Estout and VIF - Correction
Date   Tue, 12 Apr 2005 10:46:45 +0200

Dear Ben:

It works perfectly. (I also tried the tolerance and sqrt(VIF) "for the pleasure". It's also fine).

I am very grateful and appreciate your constant help to expand the possibilities of -estout-.

Best regards

Herv�

***********************************************************
Professeur/Professor
Coordinateur du D�partement/Head of Department
HEC Paris
D�partement Comptabilit� Contr�le de gestion / Dept of Accounting and Management Control
1, rue de la Liberation
78351 - Jouy-en-Josas
France
Tel: +33 1 39 67 94 42 - Fax: +33 1 39 67 70 86
[email protected]
http://campus.hec.fr/profs/stolowy/perso/home.htm
>>> [email protected] 12/04/05 9:24 >>>
As Herv� pointed out, the example code in my last message had 
the problem, that the constant was not treated correctly. 
Below is a more elaborated version of the code. Note that 
with this program it is also possible to store the tolerance, 
i.e. 1/VIF, and sqrt(VIF).

program define _estadd_vif, eclass
 syntax [ , prefix(name) TOLerance SQRvif * ]
//copy coefficients matrix and set to .z
 tempname results results2 results3
 matrix `results' = e(b)
 forv j = 1/`=colsof(`results')' {
  mat `results'[1,`j'] = .z
 }
 if "`tolerance'"!="" mat `results2' = `results'
 if "`sqrvif'"!="" mat `results3' = `results'
//compute VIF and add to results vector
 capture vif
 if !_rc {
  local i 0
  local name "`r(name_`++i')'"
  while "`name'"!="" {
   local j = colnumb(`results',"`name'")
   if `j'<. {
    matrix `results'[1,`j'] = r(vif_`i')
    if "`tolerance'"!="" matrix `results2'[1,`j'] = 1 / r(vif_`i')
    if "`sqrvif'"!="" matrix `results3'[1,`j'] = sqrt( r(vif_`i') )
   }
   local name "`r(name_`++i')'"
  }
 }
//return the results
 if "`sqrvif'"!="" ereturn matrix `prefix'sqrvif = `results3'
 if "`tolerance'"!="" ereturn matrix `prefix'tolerance = `results2'
 ereturn matrix `prefix'vif = `results'
end

Save the code as "_estadd_vif.ado" somewhere in the adopath.
To add VIF to the e-returns, type

 . estadd , stats(vif)

To additionally save the tolerance and sqrt(VIF), type

 . estadd , stats(vif(tolerance sqrvif))

To tabulate the results using -estout-, type

 . estout , cells(vif tolerance sqrvif)

ben

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Herve STOLOWY
> Sent: Monday, April 11, 2005 11:22 PM
> To: [email protected]
> Subject: Re: st: RE: Estout and VIF
> 
> 
> Dear Ben:
> 
> Once again, I sincerely appreciate your help. I followed your 
> suggestions and it works perfectly. (I saved your program as 
> an ado file).
> 
> I can simply mention one little detail (but so minor): on the 
> constant line, in the vif column, a figure is disclosed. It 
> is not a VIF but the repetition of the amount of the b coefficient.
> 
> Best regards
> 
> Herv�
> 

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



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