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]

Re: st: Unexpected behavior from svy: proportion


From   Austin Nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Unexpected behavior from svy: proportion
Date   Wed, 27 Mar 2013 14:18:10 -0400

Jennifer F. Sabatier (CDC/CGH/DGHA) <fvv9@cdc.gov>:

But don't use -svy: mean- or -svy: proportion- as those can give CI
including zero or one. Stick with -svy: tab- (check out the manual
entries for more detail on how the calculations are done, using a
logit transformation).

On Wed, Mar 27, 2013 at 2:14 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> Check to see if -colvar- is a string variable. If it is, try -destring-.
>
> Nick
>
> On Wed, Mar 27, 2013 at 6:07 PM, Sabatier, Jennifer F. (CDC/CGH/DGHA)
> <fvv9@cdc.gov> wrote:
>>
>>
>> I am trying to get simple proportions and confidence intervals and sample frequencies from a subpopulation in survey data.
>>
>>
>> So far this works:
>>
>> svy, subpop(if subpop1==1 & subpop2 == 1 & subpop3 == 1): tab rowvar colvar, ci per col obs missing nolabel
>>
>> Then I saw I could use svy: prop.  I'm a very novice user, by the way, though I am very skilled in SAS and R. R is my go-to program and I use it most of all.  But a lot of my collaborators use Stata so I translate code when necessary, and will perform analyses in Stata if asked.  I mention all of that so you'll know I am not totally unfamiliar with statistical programming.
>>
>> In this case, the original code was in SAS:
>>
>> proc surveyfreq data=dta missing;
>> cluster psu;
>> weight wght;
>> tables subpop1*subpop2*subpop3*rowvar*colvar / cl(type=logit) col;
>> run;
>>
>>
>> So, the svy: tab code gives me very similar results as proc surveyfreq.  One thing that's different is the while they both give the same SE, the confidence intervals in Stata are slightly narrower than those from SAS.  But that's not why I'm here.
>>
>> A colleague of mine who uses Stata regularly advised I try svy:prop.  So I did and I failed.
>>
>>
>> This is the code:
>>
>> svy: mean colvar , over(subpop1 subpop2 subpop3 rowvar)
>>
>> But it doesn't work.  I get this error:
>>
>> no observations
>> r(2000);

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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