Announcement

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

  • Calculating ratios

    In a sample of a population,. I would like to calculate the ratio of mobile ownership percentage among women to that of among men and then see how this differs by various demographic characteristics such as district, level of education...etc.

    Let's say that I have two variables: sb1q4 whose two values are "male" and "female", sc2q05 whose three values are "mobile phone", "smart phone", "none of the above", Let's make a variable for ownership of any mobilephone through "gen byte mob = inlist(sc2q05, 1, 2)". I want to divide the percentage of mobile ownership among females to the percentage of mobile ownership among males to simply gauge the level of equality of ownership of such technology between the two genders in a certain population, this is done by seeing how close is the percentage of the females to that of the males, 100% being ofcourse equal. How would I do this?

    Ideally, the result should look something like this if I were to calculate the level of mobile ownership equality between the two genders by their respective marital status:

    Code:
                | Summary of
                |  femaledividedbymale
                |     
          state |        Mean
    ------------+------------
      unmarried / never married |         32.6
      currently married |        67.4
      widow / widower |        91.2
    ------------+------------
          Total |        63.7
    Here is some data:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte sb1q4
    1
    2
    2
    2
    2
    1
    1
    1
    1
    2
    2
    2
    2
    1
    2
    1
    1
    2
    1
    2
    2
    1
    2
    1
    2
    1
    1
    1
    2
    2
    1
    2
    2
    1
    2
    1
    2
    1
    1
    2
    1
    1
    2
    2
    1
    1
    1
    1
    2
    2
    1
    2
    1
    2
    2
    2
    1
    1
    2
    2
    2
    2
    2
    2
    2
    1
    2
    2
    2
    2
    1
    1
    2
    2
    1
    1
    2
    1
    2
    2
    1
    2
    2
    1
    2
    1
    1
    1
    1
    1
    2
    2
    2
    1
    2
    1
    2
    1
    1
    2
    end
    label values sb1q4 sb1q4
    label def sb1q4 1 "male", modify
    label def sb1q4 2 "female", modify
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte sc2q05
    1
    1
    3
    3
    3
    3
    3
    3
    1
    3
    2
    3
    3
    3
    2
    3
    3
    3
    2
    2
    3
    1
    3
    3
    3
    1
    3
    3
    1
    1
    3
    1
    3
    2
    1
    2
    1
    3
    3
    3
    2
    2
    3
    1
    3
    3
    3
    2
    3
    3
    2
    1
    1
    3
    3
    3
    3
    3
    3
    1
    3
    3
    3
    3
    3
    1
    2
    1
    3
    3
    3
    1
    3
    1
    1
    2
    3
    1
    3
    3
    1
    3
    3
    3
    1
    3
    3
    3
    3
    1
    3
    3
    3
    1
    2
    3
    3
    3
    3
    3
    end
    label values sc2q05 sc2q05
    label def sc2q05 1 "mobile phone", modify
    label def sc2q05 2 "smart phone", modify
    label def sc2q05 3 "none of above", modify
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte sb1q7
    2
    2
    1
    1
    1
    1
    1
    1
    2
    2
    2
    1
    1
    1
    2
    1
    1
    3
    2
    2
    1
    2
    2
    2
    2
    1
    1
    1
    2
    3
    1
    1
    1
    2
    2
    2
    2
    1
    1
    2
    1
    1
    1
    3
    1
    1
    1
    1
    3
    1
    2
    2
    1
    1
    1
    1
    1
    1
    1
    2
    1
    1
    1
    1
    1
    2
    2
    2
    1
    1
    1
    2
    2
    3
    1
    1
    1
    1
    3
    1
    2
    2
    1
    1
    2
    1
    1
    1
    1
    2
    2
    1
    1
    2
    2
    1
    1
    1
    2
    2
    end
    label values sb1q7 sb1q7
    label def sb1q7 1 "unmarried / never married", modify
    label def sb1q7 2 "currently married", modify
    label def sb1q7 3 "widow / widower", modify

  • #2
    Lots of ways to do it. Stata's "table" commands perhaps.

    Here's an obvious way:
    Code:
    summ mob if sb1q4=="male"
    local male = r(mean)
    summ mob if sb1q4=="female"
    di "Ratio Female/Male = " %5.3f r(mean)/`male'

    Comment


    • #3
      Joseph:
      exploiting one of your codes only and elaborating on that, you may want to consider something along the lines of the following toy-example:
      Code:
      . input byte sc2q05
      . label values sc2q05 sc2q05
      . label def sc2q05 1 "mobile phone", modify
      . label def sc2q05 2 "smart phone", modify
      . label def sc2q05 3 "none of above", modify
      . g gender=runiform()
      . replace gender=0 if gender<=.5
      . replace gender=1 if gender>.5
      . label define gender 0 "Female" 1 "Male"
      . label val gender gender
      . mlogit sc2q05 i.gender
      
      Iteration 0:   log likelihood = -89.881897  
      Iteration 1:   log likelihood = -89.617784  
      Iteration 2:   log likelihood = -89.617156  
      Iteration 3:   log likelihood = -89.617156  
      
      Multinomial logistic regression                         Number of obs =    100
                                                              LR chi2(2)    =   0.53
                                                              Prob > chi2   = 0.7674
      Log likelihood = -89.617156                             Pseudo R2     = 0.0029
      
      -------------------------------------------------------------------------------
             sc2q05 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
      --------------+----------------------------------------------------------------
      mobile_phone  |
             gender |
              Male  |  -.2411621    .484835    -0.50   0.619    -1.191421     .709097
              _cons |  -.8574502   .3189539    -2.69   0.007    -1.482588    -.232312
      --------------+----------------------------------------------------------------
      smart_phone   |
             gender |
              Male  |   .2494609   .6108684     0.41   0.683    -.9478192    1.446741
              _cons |  -1.704748   .4438127    -3.84   0.000    -2.574605   -.8348912
      --------------+----------------------------------------------------------------
      none_of_above |  (base outcome)
      -------------------------------------------------------------------------------
      
      .
      PS: crossed in the cyberspace with George's helpful reply.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Originally posted by George Ford View Post
        Lots of ways to do it. Stata's "table" commands perhaps.

        Here's an obvious way:
        Code:
        summ mob if sb1q4=="male"
        local male = r(mean)
        summ mob if sb1q4=="female"
        di "Ratio Female/Male = " %5.3f r(mean)/`male'
        The first command
        Code:
         summ mob if sb1q4=="male"
        gives the error "type mismatch".

        If I understand correctly, your solution would seem only to involve two variables: gender and the mobile ownership percentage, thus it would merely calculate the ratio for the overall sample and that would be it. Whereas I would like to calculate the ratio by various demographic characteristics such as district, region, level of education of the males or females...etc.

        If it were possible to come up with a variable "div" which is simply female mobile ownership rate divided by the male mobile ownership rate (remember, mobile ownership here means both mobile and smartphone ownership) and then simply do "tab district div" which would tell us how the ratio prevails in different districts, it would be wonderful.

        With such a simple command, one would then be also capable of doing "tab district div if region==2 & inrange(education, 13, 15)" which shows how the ratio prevails in all "urban" portions of the districts (region==2 being urban) among people with a bachelor or associates degree (education, 13, 15 being associate to bachelor). Perhaps summarize can be involved somehow in this by formatting div as "gen div_100=div*100" and then "format 100 %6.1f" and then pulling a "tab district, summarize(div_100) means noobs"?
        Last edited by Joseph Stein; 16 Nov 2022, 07:35.

        Comment


        • #5
          You said "male", but it looks like a 1/2.

          Code:
          summ mob if sb1q4==1
          local male = r(mean)
          summ mob if sb1q4==2
          di "Ratio Female/Male = " %5.3f r(mean)/`male'

          Comment


          • #6
            Originally posted by George Ford View Post
            You said "male", but it looks like a 1/2.

            Code:
            summ mob if sb1q4==1
            local male = r(mean)
            summ mob if sb1q4==2
            di "Ratio Female/Male = " %5.3f r(mean)/`male'
            That works but is only for the sample overall whereas I want to calculate that ratio by various demographic characteristics. To put it simply, I want to gauge the level of mobile ownership equality between the two genders in various areas/districts and also see how it differs in urban educated respondents aged 15-49 living in 'ford', this is just a random example that I came up with. Any idea how to involve atleast three or four variables in this?

            Comment


            • #7
              I'd use regression.

              Consider the variables you've offered: gender, marriage.

              Code:
              reg mob b1.sb1q4##b1.sb1q7
              You'll have all the coefficients to compute the ratios. In this case, the constant of the regression is male/unmarried.

              And the t-test are useful, and joint tests can be conducted on summed coefficients.

              Can get means using:
              Code:
              margins, over(sb1q4 sb1q7)
              Last edited by George Ford; 16 Nov 2022, 08:20.

              Comment


              • #8
                Originally posted by George Ford View Post
                I'd use regression.

                Consider the variables you've offered: gender, marriage.

                Code:
                reg mob b1.sb1q4##b1.sb1q7
                You'll have all the coefficients to compute the ratios. In this case, the constant of the regression is male/unmarried.

                And the t-test are useful, and joint tests can be conducted on summed coefficients.

                Can get means using:
                Code:
                margins, over(sb1q4 sb1q7)
                I'd like to stick with simple ratios for now, is there any way to get the percentages in an order like:

                Code:
                 
                             | Summary of             |  femaledividedbymale             |            state |        Mean ------------+------------   unmarried / never married |         32.6   currently married |        67.4   widow / widower |        91.2 ------------+------------       Total |        63.7

                Comment


                • #9
                  This might be useful.

                  HTML Code:
                  https://www.youtube.com/watch?v=ug0LihyIzvM

                  Comment

                  Working...
                  X