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]
st: Error in 2008 post on survey covariances
From 
 
Steven Samuels <[email protected]> 
To 
 
[email protected] 
Subject 
 
st: Error in 2008 post on survey covariances 
Date 
 
Tue, 21 Dec 2010 18:52:36 -0500 
-
Marlous Tuithof found a mistake in a formula I posted in 2008 for  
computing covariances for survey data (see:http://www.stata.com/statalist/archive/2008-10/msg00087.html).I 
 am posting corrected code below.  For those who need survey  
correlations, I recommend Nick Winter's -corr_svy-, available at SSC.   
I informed the original poster and I apologize to anyone else who used  
the code.
Steve
[email protected]
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fax:    206-202-4783
*******************************************************
* Get covariances for survey data
* CORRECTED  2010-12-20
*******************************************************
sysuse auto,clear
svyset _n [pweight=rep78]
gen wt1000=weight/1000         // avoid large values
local cvars mpg wt1000 trunk  //variable list
svy: mean `cvars'
foreach w of varlist `cvars' {
foreach v of varlist `cvars' {
gen double c_`w'_`v' = (`w' - _b[`w'])*(`v' - _b[`v'])
}
}
svy: mean c_*
*****************CODE ENDS*************************
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/