Announcement

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

  • How to calculate the Standard Deviation of a Variable in a Paneldata set

    Hello,

    I am new to Statalist, so please apologize any mistakes or insufficient descriptions.

    I am currently working with a paneldata set, in which firm is my panel and year my time variable. Among amother variables, I have a variable called sale.
    I now want to calculate the standard deviation of the variable sale for each firm-year observation. I have tried the following:

    1) egen sale_sd=sd(sale), by(firm) --> That way I receive for a firm in each year the same SD
    2) egen sale_sd=sd(sale), by(year) --> That way I receive for a year in each firm the same SD
    3) bysort firm year: egen sale_sd=sd(sale) --> That way I receive missing values only
    4) egen sale_sd=sd(sale), by(firm year) --> Same as 3)

    Can you help me out? Is there any possibility for my calculations?

    Thanks and best regard

  • #2
    As you say 3) and 4) are the same calculation.

    My guess that is (firm, year) couples define single observations and so there is no variability to summarize. It's on all fours with what is the standard deviation of 42? or of 2.71828?

    You get missing not zero because Stata calculates standard deviation using (sample size MINUS 1) in the denominator; the consequent attempt to divide by zero when the sample size is 1 yields a missing result.

    Comment


    • #3
      A firm-year in a panel dataset is an observation (assuming that the panel identifier is firm and time variable is year). An observation is constant - i.e., has no variance. So you need to rethink what you want to do.

      Comment

      Working...
      X