Announcement

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

  • ci for categorial variables - tabci?

    I'm just wondering why Stata gives CIs for binary variables - ci proportions varname - but, as far as I tried to find, we cannot have results for categorical variables.

    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . ci proportions foreign
    
                                                             -- Binomial Exact --
        Variable |        Obs  Proportion    Std. Err.       [95% Conf. Interval]
    -------------+---------------------------------------------------------------
         foreign |         74    .2972973    .0531331         .196584    .4148353
    
    . ci proportions rep78
    no binary (0/1) variables found; nothing to compute
    Am I missing something, is it technically impossible or we just don't have a user-written program to estimate these proportions with CIs in Stata?

    If it can be done, and considering (and maybe I'm wrong) we don't have it so far, maybe this thread could foster somebody to create, say, a SSC (or SJ) - tabci - ado file.
    Best regards,

    Marcos

  • #2
    Marcos:
    I think that -rep78- takes on positive numeric integers only (ie, the Repair Record during 1978).
    Hence, I would calculate the 95% CI for the mean via:
    Code:
    ci means rep78, poisson
    . ci means rep78, poisson
    
                                                             -- Poisson  Exact --
        Variable |   Exposure        Mean    Std. Err.       [95% Conf. Interval]
    -------------+---------------------------------------------------------------
           rep78 |         69    3.405797    .2221697        2.984238    3.870221
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Marcos Almeida I think this comes under at least one heading, multinomial confidence intervals, and many methods have been suggested, but fewer (no???) Stata implementations.

      Comment


      • #4
        *If* (a big if) you satisfied with CIs for each category's proportion treated as independent of the others, you can run -mlogit- without any explanatory variables, and follow it with -margins-. This amounts to just a convenient way to get the asymptotic CIs you would get from running -ci proportions- on a binary variable for each category.
        Last edited by Mike Lacy; 30 Sep 2019, 19:15.

        Comment


        • #5
          Marcos:
          if you did not come across it yet, there's something on the topic you're interested in at: https://www.statalist.org/forums/for...al-proportions
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Nick Cox Carlo Lazzaro Mike Lacy : thank you for the remarks and suggestions.

            Hopefully we'll have a Stata implementation concerning this issue.
            Best regards,

            Marcos

            Comment


            • #7
              I tried bootstrapping this problem, which gave me essentially the same results as -mlogit-. I do know there are various fancier solutions to this, per Nick's comment, which I should think would give different results than mlogit, but I'd think of the bootstrap as the gold standard. Is there anything conceptually wrong with just bootstrapping the following?
              Code:
              clear
              cap prog drop mp
              prog mp, rclass
              syntax varlist
              tempname f
              quiet tab `varlist', matcell(`f')
              mat `f' = `f'/r(N)
              forval i = 1/`=rowsof(`f')' {
                 return scalar p`i' = `f'[`i',1]
              }
              end

              Comment

              Working...
              X