Announcement

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

  • Comparing Dominance Statistics Between Subgroups

    Dear Statalist users!

    I'm estimating dominance statistics using domin for separate models by subgroup (gender in my case) with bootstrapped confidence intervals. Using test, I can easily test for differences between the dominance statistics within one model/subgroup. Instead, I would like to test for differences for the same indicator between the two subgroup-models.

    To illustrate my problem, I'd like to share some syntax:

    Code:
    webuse auto, clear
    
    *Dominance analyses with bootstrapping
    bootstrap, reps(50): domin price mpg headroom
    
    *Bootstrapped results
    estat bootstrap
    
    *Comparing dominance statistics within the model - no problem
    test mpg = headroom
    
    *Beginning of subgroup analyses:
    *Clear stored estimates just in case
    eststo clear
    
    *Repeating the previous bootstrapping over the two foreign categories
    bysort foreign: eststo: bootstrap, reps(50): domin price mpg headroom
    
    *Testing within the (last estimated) model still works
    test mpg = headroom
    
    *Showing stored estimates - subgroup estimates are stored as est1 and est2. I want to compare the estimates for mpg between the two subgroups
    eststo dir
    
    *It might look something like this, but I just can't seem to find the right syntax to access the estimates from each model - if it is even possible
    test [est1]mpg = [est2]mpg
    Does anyone know how to do this? Thank you so much in advance!

  • #2
    Hi Pat,

    Those subgroups can't be compared directly I believe with -domin- and -bootstrap- but it could be accomplished using a custom program like:

    Code:
    . program define bs_mpg, rclass
      1. domin price mpg headroom if foreign
      2. local foreign = _b[mpg]
      3. domin price mpg headroom if !foreign
      4. local domestic = _b[mpg]
      5. return scalar diff = `foreign' - `domestic'
      6. end
    The idea is that they run -domin- on separate subgroups, collect the value from mpg, and then difference them. The value that's retuned, and bootstrapped, is the returned difference.

    The result produced looks something like this:

    Code:
    . sysuse auto
    (1978 automobile data)
    
    . bs r(diff), reps(50) nodrop: bs_mpg
    (running bs_mpg on estimation sample)
    
    Bootstrap replications (50)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
    ..................................................    50
    
    Bootstrap results                                           Number of obs = 74
                                                                Replications  = 50
    
          Command: bs_mpg
            _bs_1: r(diff)
    
    ------------------------------------------------------------------------------
                 |   Observed   Bootstrap                         Normal-based
                 | coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           _bs_1 |   .1499008   .1823134     0.82   0.411    -.2074268    .5072284
    ------------------------------------------------------------------------------
    Joseph Nicholas Luchman, Ph.D., PStatĀ® (American Statistical Association)
    ----
    Research Fellow
    Fors Marsh

    ----
    Version 18.0 MP

    Comment


    • #3
      Thank you so much, that really helps me a lot!

      Some addition for anyone finding this later: You can also get multiple comparisons with one run like this:

      Code:
      program define bs_diffs, rclass
      domin price mpg headroom weight if foreign
      local foreign_mpg = _b[mpg]
      local foreign_headroom = _b[headroom]
      local foreign_weight = _b[weight]
      domin price mpg headroom weight if !foreign
      local domestic_mpg = _b[mpg]
      local domestic_headroom = _b[headroom]
      local domestic_weight = _b[weight]
      return scalar diff_mpg = `foreign_mpg' - `domestic_mpg'
      return scalar diff_headroom = `foreign_headroom' - `domestic_headroom'
      return scalar diff_weight = `foreign_weight' - `domestic_weight'
      end
      
      sysuse auto
      bs r(diff_mpg) r(diff_headroom) r(diff_weight), reps(50) nodrop: bs_diffs
      And it also works with sets of variables like this:

      Code:
      program define bs_sets, rclass
      domin price if foreign, sets((mpg headroom) (weight)) reg(regress) fitstat(e(r2))
      local foreign_set1 = _b[set1]
      local foreign_set2 = _b[set2]
      domin price if !foreign, sets((mpg headroom) (weight)) reg(regress) fitstat(e(r2))
      local domestic_set1 = _b[set1]
      local domestic_set2 = _b[set2]
      return scalar set1 = `foreign_set1' - `domestic_set1'
      return scalar set2 = `domestic_set1' - `domestic_set2'
      end
      
      sysuse auto
      bs r(set1) r(set2), reps(1000) nodrop: bs_sets

      Comment


      • #4
        Correction of a copy-paste mistake in the sets-code:

        Code:
        program define bs_sets, rclass
        domin price if foreign, sets((mpg headroom) (weight)) reg(regress) fitstat(e(r2))
        local foreign_set1 = _b[set1]
        local foreign_set2 = _b[set2]
        domin price if !foreign, sets((mpg headroom) (weight)) reg(regress) fitstat(e(r2))
        local domestic_set1 = _b[set1]
        local domestic_set2 = _b[set2]
        return scalar set1 = `foreign_set1' - `domestic_set1'
        return scalar set2 = `foreign_set2' - `domestic_set2'
        end
        Speaking of it, if you are doing a lot of error prone copy-pasting it might help to add a line to delete the program before defining it for corrections on the fly:

        Code:
        capture program drop bs_sets
        Also, if you add more and more comparisons to the code (e.g., within models and between models, multiple variables/sets), it might be helpful to add labels to them like this:

        Code:
        bs Diff_Set1 = r(set1) Diff_Set2 = r(set2), reps(50) nodrop: bs_sets

        Comment

        Working...
        X