Announcement

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

  • confidence interval of coefficient of variation

    Hi! All,
    How can I calculate the 95% confidence interval of coefficient of variation?

  • #2
    You can use bootstrap command to calculate the CI. here is a small program to do that:
    Code:
    cap program drop coef_v
    program define coef_v, rclass
    quietly summarize `1'
    return scalar CV =  r(sd)/ r(mean)
    end
    
    sysuse auto, clear
    bootstrap r(CV), reps(200) bca: coef_v price
    estat bootstrap, all

    Comment


    • #3
      Thank you so much, Oded!
      I have a question.
      Could you tell me the meaning of 'reps(200)'?
      Default is 50.
      Last edited by Jeong-Kweon Park; 06 Dec 2016, 19:05.

      Comment


      • #4
        Hello, Oded!
        I understood the meaning of 'reps(200)'.
        I have another question.
        What is `1'?

        Comment


        • #5
          The `1' in Stata programming language refers to the first variable in the program. the program above is based on results from summarize command, so only the first variable after the name of the program, in this case coef_v, is passed to the summarize command.

          Comment


          • #6
            If I could use 'bootstrap r(CV), reps(200) bca: coef_v price mpg rep78 headroom' command?

            Comment


            • #7
              No; the program only takes a single variable. You would need to loop over variables.

              Code:
              sysuse auto, clear  
              foreach v in price mpg rep78 headroom {
                    bootstrap r(CV), reps(200) bca: coef_v `v'    
                    estat bootstrap, all
              }

              Comment


              • #8
                Thank you so much, Nick!

                Comment

                Working...
                X