Announcement

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

  • Coefficient of variation

    I have two data sets and I would like to investigate differences in terms of
    median, standard deviation and coefficient of variation(cv).
    For SD I have found sdtest (Bartlett / Levene) but how do I test for differences of the CVs?

  • #2
    Claus:
    welcome to this forum.
    Despite -cv-being currently almost side-tracked (see https://www.amazon.com/Principles-Bi.../dp/0534229026), you can do what you have in mind via -bootstrap-, like in the following toy-example (which, in turn, heavily relies on Example 4, -bootstrap- entry, Stata .pdf manual):
    Code:
    program myratio, rclass
    version 15.1
    args y
    confirm var `y'
    tempname cv
    summarize `y' if foreign==0
    scalar `cv' = r(sd)/r(mean)
    summarize `y' if foreign==1
    return scalar ratio = `cv'/(r(sd)/r(mean))
    end
    use http://www.stata-press.com/data/r15/auto, clear
    summarize price if foreign==0
    scalar mean1=(r(sd)/r(mean))
    summarize price if foreign==1
    scalar mean2=(r(sd)/r(mean))
    di scalar(mean1)/scalar(mean2)
    myratio price
    set seed 12345
    bootstrap ratio=r(ratio), reps(1000) nowarn nodots: myratio price
    estat bootstrap
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Claus:
      I would change the last two lines of my previous code as follows:
      Code:
      bootstrap ratio=r(ratio), reps(1000) nowarn nodots strata(foreign): myratio price
      estat bootstrap, all
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Coefficients of variation are typically unstable and skewed, so watch out.

        Whenever a coefficient of variation makes sense, it's usually a sign that you are better off working on a logarithmic scale.

        https://stats.stackexchange.com/tags...-variation/hot leads to several discussions.

        Comment


        • #5
          No need to bootstrap (though that will work of course). You can get standard errors for "half of the coefficient of variation squared" (the generalised entropy inequality measure with parameter value = 2) by using the svygei program on SSC: ssc install svygei_svyatk . Then apply the delta method to derive the SE for the CV itself.

          Comment

          Working...
          X