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 on April 23, and its replacement, 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 <>
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: 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.

18 Cantine's Island
Saugerties NY 12477
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:

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