Announcement

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

  • Finding the response rate to questionnaire

    Dear Statalist,

    I have a survey data about the respondents' beverage intake information across multiple waves, and I need to make the following statement, "X out of XX people responded to at least Y out of YY waves," until YY hits maximum. That is, I need to make a series of statements as following:
    • 99 out of 100 people responded to at least 1 of 10 survey waves.
    • 79 out of 100 people responded to at least 2 out of 10 survey waves.
    • 71 out of 100 people responded to at least 3 out of 10 survey waves.
    • ... and so forth until "10 out of 10 survey waves".
    As for the waves, I'm not interested in the nth survey but the number of waves of response itself: i.e. if the person responded to Wave 2 and Wave 9 out of the total of 10 waves, s/he responded to just 2 surveys. I don't care about the fact that s/he responded to 2nd and 9th waves.

    At the bottom is a brief sample data I prepared. I created some missing values in the three of the variables I'm using for the sake of this question (to simulate no response). I renamed rep78, trunk, headroom, and gear_ratio as drinkA1, drink A2, and drinkB1, and drinkB2, respectively.

    Here's the information for these variables:
    drinkA1: drink type A from wave 1 (categorical, e.g. "How often did you drink A this past week? Choose from the following options: 'Never',...'Everyday'")
    drinkA2: drink type A from wave 2 (categorical as above--please disregard the non-sensical numbers for this variable)
    drink B1: drink type B from wave 1 (continuous, e.g. "How many bottles of drink B did you drink past week? Write this number down and we will convert it into a daily intake")
    drinkB2: drink type B from wave 2 (continuous as above)
    id: respondent ID

    Of note, if the person made a response as to drinkA1 but not drinkB1, it'd count as having responded to wave 1.

    How might I approach this? I hope I'm making sense, at least. Please let me know if you need further clarification. Thank you!


    Kevin

    p.s. I'm using Stata 16.1.

    ----------

    sysuse auto, clear
    gen id=_n
    gen p=invlogit(.1*mpg + rep78 -8)
    sum p
    replace headroom=. if uniform() <p
    replace trunk=. if uniform() <p
    rename (trunk headroom gear_ratio rep78) (drinkA2 drinkB1 drinkB2 drinkA1)
    keep drinkA1 drinkA2 drinkB1 drinkB2 id
    Last edited by Kevin Rhee; 15 Mar 2021, 18:53.

  • #2
    Kevin:
    the following toy-example calculates the number of respondents per wave:
    Code:
    . use "https://www.stata-press.com/data/r16/nlswork.dta"
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    . duplicates tag idcode, g(numb_waves)
    
    Duplicates in terms of idcode
    
    . replace numb_waves= numb_waves+1
    (28,534 real changes made)
    
    . tab numb_waves
    
     numb_waves |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |        547        1.92        1.92
              2 |        996        3.49        5.41
              3 |      1,452        5.09       10.50
              4 |      1,644        5.76       16.26
              5 |      2,105        7.38       23.63
              6 |      2,388        8.37       32.00
              7 |      2,415        8.46       40.47
              8 |      2,584        9.06       49.52
              9 |      2,718        9.53       59.05
             10 |      2,700        9.46       68.51
             11 |      2,222        7.79       76.30
             12 |      1,896        6.64       82.94
             13 |      1,911        6.70       89.64
             14 |      1,666        5.84       95.48
             15 |      1,290        4.52      100.00
    ------------+-----------------------------------
          Total |     28,534      100.00
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3

      Code:
      bysort id : gen wanted = _N 
      by id : gen tag = _n == 1
      tab wanted if tag

      Comment

      Working...
      X