Announcement

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

  • Error of "invalid subcommand cv" after estat cv

    Hello,

    I would like to calculate the coefficient of variation for a give variable. So I run -mean variable- and -estat cv-.
    However, then Stata reports "invalid subcommand cv" (r(321)).
    If I run -estat sd-, then it works.
    So why Stata gave such an alert for estat cv? and what shall I do for this problem?

    Thank you very much.

  • #2
    Well, the surprise is not that -estat cv- didn't work, but that -estat sd- did! The help for mean postestimation shows that the only thing you can get from -estat- following -mean- is estat vce. You can get a coefficient of variation with -estat cv- after -svy: mean-. To do that, however, you must first -svyset- your data.

    Comment


    • #3
      Alex:
      the cv of a given variable is the ratio between its standard deviation and mean (usually expressed in pecentage terms).
      If you do not have the chance to -svy- your data, what follows will do the trick:
      Code:
      . sysuse auto.dta
      (1978 Automobile Data)
      
      . quietly sum price
      
      . di (r(sd)/r(mean))*100
      47.840601
      In this toy-example, the cv is about 47.48%
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Originally posted by Carlo Lazzaro View Post
        Alex:
        the cv of a given variable is the ratio between its standard deviation and mean (usually expressed in pecentage terms).
        If you do not have the chance to -svy- your data, what follows will do the trick:
        Code:
        . sysuse auto.dta
        (1978 Automobile Data)
        
        . quietly sum price
        
        . di (r(sd)/r(mean))*100
        47.840601
        In this toy-example, the cv is about 47.48%
        Dear Clyde and Carlo,
        Thank you so much! Actually, when I run -estat cv- after svyset with adjustment of cluster (psu) and stratum (strata), cv cannot be calculated, because STATA reports "Missing standard error because of stratum with single sampling unit".

        If I do not adjust cluster and stratum but only take into account sampling weight (pweight), then cv can be reported.

        But I am not sure if such a cv without adjusting cluster and stratum is reliable.

        Thank you again!

        Comment


        • #5
          Alex:
          no, you cannot ignore the survey structure of your data.
          My previous toy-example assumed that your data were not structured that way.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Originally posted by Carlo Lazzaro View Post
            Alex:
            no, you cannot ignore the survey structure of your data.
            My previous toy-example assumed that your data were not structured that way.
            Dear Carlo,

            Thank you! So does it mean that with such a survey database (with singleton strata) it is not possible to calculate correct CV?
            In an answer to a previous post, Clyde suggested to re-assign singleton strata to other strata, but this may not be easy (because of the choice of a suitable target stratum, and the large number of singleton strata in my database).

            Comment


            • #7
              Alex:
              I'm not an expert in survey data analysis.
              Soory I cannot be more helpful.
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                Originally posted by Carlo Lazzaro View Post
                Alex:
                I'm not an expert in survey data analysis.
                Soory I cannot be more helpful.
                Thank you!

                Comment


                • #9
                  Thank you! So does it mean that with such a survey database (with singleton strata) it is not possible to calculate correct CV?
                  In an answer to a previous post, Clyde suggested to re-assign singleton strata to other strata, but this may not be easy (because of the choice of a suitable target stratum, and the large number of singleton strata in my database).
                  As far as I know, there is no way around this.

                  Comment


                  • #10
                    Originally posted by Clyde Schechter View Post
                    As far as I know, there is no way around this.
                    Dear Clyde,
                    Thank you! I just now read from other posts about the option of singleunit after -strata()- (it is recommended to use singleunit (centered)). I tried this and it indeed worked for producing CV for database with singleton stratum.
                    Is this a good method to solve the singleton problem?

                    Thank you!

                    Comment


                    • #11
                      I'm not familiar with it, and I don't really know. Perhaps somebody else will answer this.

                      Comment


                      • #12
                        Originally posted by Clyde Schechter View Post
                        I'm not familiar with it, and I don't really know. Perhaps somebody else will answer this.
                        Thank you!

                        Comment

                        Working...
                        X