Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Error in 2008 post on survey covariances


From   Steven Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
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

sjsamuels@gmail.com
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/


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