Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with Testing Difference of Proportion in Survey Dataset

    Hi Statalist members,

    I am having difficulty in testing a difference of proportion. I am currently using a nationally representative dataset (thus svy command) and interested in the use of nicotine product (either cigarettes or e-cigarettes) in school. I have two groups (smokers and e-cigarette users), although there are dual cigarette and e-cigarettes users.
    I already have the proportion of use of their respective products in schools (smokers: 45.8% [95%CI 12.9%-78.7%] and e-cigarette users: 69.4% [95%CI 41.4%-97.5%]), however I am interested to see if there is a difference between proportion between the two groups. I am wondering how could I test it?
    Attached below is a fraction of my dataset. Any help would be greatly appreciated. Thank you very much.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(Smokers Vapers Smoke_School Vape_School Survey_Weight Unique_ID)
    1 0 1 . 2734.12  1
    0 1 . 1 3498.22  2
    1 0 1 .  130.29  3
    1 0 1 . 1231.22  4
    1 1 0 1  490.43  5
    1 1 1 1 2342.11  6
    0 1 . 0 3453.56  7
    0 1 . 0  636.78  8
    1 1 1 1 2956.23  9
    0 1 . 1 3453.22 10
    0 1 . 1 2341.19 11
    0 1 . 0 3458.54 12
    1 0 0 . 1989.24 13
    1 0 0 . 2312.33 14
    1 1 0 1 3432.11 15
    1 0 0 .  657.45 16
    1 1 0 0  456.94 17
    1 0 1 .  357.23 18
    0 1 . 0  689.23 19
    1 1 1 1 1423.12 20
    0 1 . 1 2425.23 21
    1 0 0 . 2345.11 22
    0 1 . 1 1632.12 23
    0 1 . 0 1982.12 24
    1 1 1 1  267.42 25
    1 0 0 . 1838.38 26
    end
    label values Smokers var1
    label def var1 0 "No", modify
    label def var1 1 "Yes", modify
    label values Vapers Vapers
    label def Vapers 0 "No", modify
    label def Vapers 1 "Yes", modify
    label values Smoke_School Smoke_Private
    label def Smoke_Private 0 "No", modify
    label def Smoke_Private 1 "Yes", modify
    label values Vape_School Vape_Private
    label def Vape_Private 0 "No", modify
    label def Vape_Private 1 "Yes", modify

  • #2
    The issue of overlapping groups arose for me recently.

    You'll need to change this code to use the proper survey settings, but here is a sketch of how to solve this:
    Code:
    svyset [pweight=Survey_Weight] // replace this line with correct settings
    
    svy: reg Smoke_School if Smokers == 1
    estimates store eq1
    
    svy: reg Smoke_School if Vapers == 1
    estimates store eq2
    
    suest eq1 eq2
    lincom [eq1]_cons - [eq2]_cons

    David Radwin
    Senior Researcher, California Competes
    californiacompetes.org
    Pronouns: He/Him

    Comment


    • #3
      The code works! Thank you very much for your help, David.

      Comment

      Working...
      X