[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Ishtar Govia <ishtargovia@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: covariance matrix for survey data |

Date |
Thu, 2 Oct 2008 21:48:00 -0500 |

Many thanks for sending along the code, Steve. Can you provide some explanation for some lines of the code so that I can understand better what exactly I would be doing to get the matrix?

Specifically, why am I only standardizing the weight variable? Should I also be standardizing the cluster and stratum variable? What exactly do the "w" and the "v" in the code to generate the n^2 covariance terms mean/represent? What would I be doing exactly in the format c_* %20.5fc line of the code and why does that number change in the code to get the covariance? (i.e. format c_* %15.5fc)

Ishtar Govia

ishtargovia@gmail.com

On Oct 2, 2008, at 1:50 PM, Steven Samuels wrote:

In addition, does anyone know how to use the matrix I am trying to obtain above to obtain a covariance matrix that can be easily transferred to Mplus or LISREL for CFA and SEM analyses?In Stata V 10 Version 10.1 corr_svy does not return the proper correlation matrix, at least for p>2 dimensions.

The following code should get you the covariance matrix in a list. I don't know anything about the programs you want to feed into, so you will have to manipulate the list yourself to suit their requirements.

********************* CODE BEGINS**********************

* Create covariance matrix for survey data

*******************************************************

sysuse auto,clear

svyset _n [pweight=rep78]

gen wt000=weight/1000 //standardize to avoid large values

********************************************************

* put variables into a macro

*******************************************************

local cvars mpg wt000 trunk

*******************************************************

* Get means

*******************************************************

svy: mean `cvars' //outputs weighted means in _b[varname]

*******************************************************

* Get n^2 covariance terms

*******************************************************

foreach w of varlist `cvars' {

foreach v of varlist `cvars' {

gen c_`w'_`v' = ((`w' - _b[`w'])^2)*((`v' - _b[`v'])^2)

}

}

format c_* %20.5fc

*******************************************************

* Get Covariances

*******************************************************

svy: mean c_*

format c_* %15.5fc

matrix clist = vec(e(b))

matrix list clist

*****************CODE ENDS*************************

On Oct 1, 2008, at 9:57 PM, Ishtar Govia wrote:

Dear List,

I am using Stata 10/SE 10.1 for Macs. I have two questions. One concerning the --corr_svy-- module and error messages I have been getting, the second concerning how to obtain a covariance matrix for complex survey sample data, within Stata.

I am working with a complex survey sample dataset and am using Stata for some preliminary data analyses (univariate and multivariate checks for normality, efas) before moving to Mplus for SEM modeling. I installed the --corr_svy-- module from within Stata by typing "ssc install corr_svy"

However, in my first attempt below, I got the following error message:

svy, subpop (if race3cat==2 & sex==1 & (riwyes==1 & riwyes <.)): corr_svy lesscurt lessresp poorserv notsmart actfraid thkdisho actbettr callnmes trethara follstor, pw obs sig

corr_svy is not supported by svy with vce(linearized); see help svy estimation for a list of Stata estimation commands that are supported by svy

r(322);

I then attempted to reset the weight and design variables, and run the --corr_svy--, following the example in the "help" for the -- corr_svy--, excluding my subpop specification.

. svyset clust [pweight=wgtcentriw], strata (stratum) ||_n

Note: stage 1 is sampled with replacement; all further stages will be ignored

pweight: wgtcentriw

VCE: linearized

Single unit: missing

Strata 1: stratum

SU 1: clust

FPC 1: <zero>

. corr_svy lesscurt lessresp poorserv notsmart actfraid thkdisho actbettr callnmes trethara follstor, pw obs sig

This worked--but it didn't include my subpop specification. I then tried the same thing with my subpop specifcation and it DIDN'T work. Any ideas on how to use the corr_svy module to obtain the correlation matrix, accounting for the weight and design variables and allowing me to restrict my analyses to my subpop of interest?

corr_svy lesscurt lessresp poorserv notsmart actfraid thkdisho actbettr callnmes trethara follstor [pweight=wgtcent], strata(stratum) psu(clust) subpop(if race3cat==2 & sex==1 & (riwyes==1 & riwyes <.)) pw obs sig print(10) star(5)

subpop() does not contain a valid varname

r(198);

. svyset clust [pweight=wgtcentriw], strata (stratum) ||_n

Note: stage 1 is sampled with replacement; all further stages will be ignored

pweight: wgtcentriw

VCE: linearized

Single unit: missing

Strata 1: stratum

SU 1: clust

FPC 1: <zero>

. corr_svy lesscurt lessresp poorserv notsmart actfraid thkdisho actbettr callnmes trethara follstor, pw obs sig

In addition, does anyone know how to use the matrix I am trying to obtain above to obtain a covariance matrix that can be easily transferred to Mplus or LISREL for CFA and SEM analyses?

Thanks for your consideration,

Ishtar Govia

ishtargovia@gmail.com

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

**References**:**st: corr_svy & covariance matrix for survey data***From:*Ishtar Govia <ishtargovia@gmail.com>

**Re: st: corr_svy & covariance matrix for survey data***From:*Steven Samuels <sjhsamuels@earthlink.net>

- Prev by Date:
**Re: st: Re: limiting observations within a program** - Next by Date:
**Re: st: corr_svy & covariance matrix for survey data** - Previous by thread:
**Re: st: corr_svy & covariance matrix for survey data** - Next by thread:
**Re: st: corr_svy & covariance matrix for survey data** - Index(es):

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