Hello Statalist community,

I am currently struggling to achieve the following: I would like to create a new variable (called KURT5) which is equal to the kurtosis.
More specifically: I have a panel dataset with 20 years of data on ~ 1,000 firms. The new variable KURT5 should be equal to the kurtosis of the observations of the focal firm in the current year (of the variable change_in_debt) and of the value of this variable for the same firm in the 5 years prior. So, KURT5 should be the kurtosis of 6 datapoints of one specific firm (six years from this specific company).

The variable "change_in_debt" shows the percentage point difference from year to year of a company in their debt level. For example, in the table below, in 2001 firm Alpha increased their debt level by 5.0%

An example:
Company Year change_in_debt
Alpha 2001 +5.0%
Alpha 2002 +5.1%
Alpha 2003 +5.0%
Alpha 2004 +5.2%
Alpha 2005 +5.1%
Alpha 2006 +5.2%
Beta 2001 +0.5%
Beta 2002 +27.9%
Beta 2003 +1.2%
Beta 2004 +76.3%
Beta 2005 +21.6%
Beta 2006 +1.6%
For each of the two firms above, I would like to calculate a kurtosis value:
  • For Firm Alpha, I would like the compute the kurtosis for the 6 datapoints from 2001-2006
  • Similar for firm Beta, I would like the compute the kurtosis for the 6 datapoints from 2001-2006
By doing so, I hope to show that:
  • Firm A changes its debt level at a constant (regular) pace: Each year they change it by ~ 5.0%
  • In contrast, firm B changes its debt level at an irregular pace: In one year they have high peaks (e.g. in 2004 + 76.3%), while in other years there is almost no change at all (e.g. in 2001 +0.5%)
Thus:
  • The constant pace of change of firm A means that it should have a relatively flat distribution. Thus, its kurtosis should be low
  • In contrast, the large peaks and the periods of inactivity of firm B means that it should have a relatively concentrated distribution. Thus, its kurtosis should be high
Thank you so much in advance for any advice on how such a variable could be computed in Stata.

Franz