Statalist


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

Re: st: corr_svy & covariance matrix for survey data


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: corr_svy & covariance matrix for survey data
Date   Thu, 02 Oct 2008 14:02:00 -0400

Hi,

I wrote -corr_svy-, so here goes.

There are a couple of things going on here: (1) -corr_svy- is a version 7 command, and seems to be having some trouble interacting with the way that Stata 10 stores the survey characteristics as set by -svyset-. (2) -corr_svy- uses the older, more limited syntax for the -subpop()- option.

Issue (2) means that your subpop option must be specified as a single variable name that takes on values 1 or 0 for cases that are in or out of your subpopulation, respectively. If you have a complex condition, you must first generate such a variable.

So, the following *should* work, but does not:

. sysuse auto
. svyset rep78 [pw=weight]
. corr_svy mpg price , subpop(foreign) sig

Survey Correlation

pweight: <none>
Strata: <one>
PSU: <observations>

Number of observations: 22

| mpg price
-------------+------------------------
mpg | 1.0000
|
|
price | -0.6313 1.0000
| 0.0042
--------------------------------------
Key: Estimated Correlation
Significance Level


As indicated in the output, -corr_svy- has ignored the survey characteristics.

However, you can specify the survey characteristics in the -corr_svy- command itself:

. corr_svy mpg price [pw=weight], psu(rep78) subpop(foreign) sig

Survey Correlation

pweight: weight
Strata: <one>
PSU: rep78

Number of observations: 21

| mpg price
-------------+------------------------
mpg | 1.0000
|
|
price | -0.5735 1.0000
| 0.0344
--------------------------------------
Key: Estimated Correlation
Significance Level


This gives you what you wanted.

(-corr_svy- will also set the survey characteristics you specify in a way that subsequent calls to -corr_svy- can see, so you really only need to specify them in the first run.)

What's going on? With version 9 Stata reworked completely the way that survey characteristics are stored, presumably to support the enhancements to the survey capabilities (such as supporting multiple rounds of sampling). -corr_svy- uses the un/non-documented Stata program -svy_get- to retrieve survey characteristics if they are not specified in the command line. Unfortunately this is a Stata 8 command, and cannot "see" the version 9+ survey characteristics.

In the long run I will fix -corr_svy- to deal with the new survey characteristics. In the short run you can simply specify them when you run -corr_svy_, or with a call to the version 8 -svyset-, like this:

. version 8: svyset ....

As a side effect, this means that -corr_svy- cannot deal with the more complex sample specifications allowed with version 9+.

- Nick Winter


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
[email protected]

*
* 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/
--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  [email protected] e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index