Hello, I previously asked a question regarding covariance of performance within group members,
yet due to my lack of knowledge, I failed to interpret kind and detailed replies for my question.
Thus, I decided to elaborate more on my dataset and on the problems I have while devising a code.
My data is a panel data that lists performance of firms for a given year (fyear), within a given industry (sich). Each firm is assigned a unique id (gvkey).
Now, I would like to see how the performance of firms in a specific industry covary across years. High covariance would imply that performance of the firms in the same industry move in the same direction across years (firms all improving or all failing compared to the year before), while low covariance would imply that their performance move rather randomly in terms of direction.
The three issues that remain unsolved while trying to devise a code is as follows.
1. Firm composition for each sich varies for each year. That is, some firms go bankrupt drop out of the industry, while new firms are added to the industry.
2. I want to create a three-year moving window to measure covariance - that is, how performance of firms within a specific industry covary across years t-2, t-1, and t. Yet I do not know how to apply this into my code.
3. I want to create a variable to save the covariance score for each observation. That is, for each firm-year-industry observation, I would to like to calculate the performance covariance measure and save it.
Yet unfamiliar with the stata package (struggling though), I would really appreciate the help from the community. Thank you!
Below is my database:
clear
input int(fyear sich) long gvkey float ni
1991 3460 1009 1.084
1992 3460 1009 2.388
1993 3460 1009 3.362
1994 3460 1009 4.855
1991 3743 1010 156.959
1992 3743 1010 -17.81
1993 3743 1010 112.249
1994 3743 1010 25.2
1995 3743 1010 84.3
1996 3743 1010 92.4
1997 3743 1010 216.4
1998 3743 1010 67.2
1999 3743 1010 77.3
2000 3743 1010 79.9
2001 3743 1010 145.7
2002 3743 1010 79.7
2003 3743 1010 352.5
1991 3661 1013 22.025
1992 3661 1013 21.026
1993 3661 1013 31.636
1994 3661 1013 39.071
1995 3661 1013 55.186
1996 3661 1013 87.463
1997 3661 1013 108.837
1998 3661 1013 146.727
1999 3661 1013 87.635
2000 3661 1013 868.1
2001 3661 1013 -1287.7
2002 3661 1013 -1145
2003 3661 1013 -76.7
2004 3661 1013 16.4
2005 3661 1013 110.7
2006 3661 1013 65.7
2007 3661 1013 106.3
2008 3661 1013 -41.9
2009 3661 1013 -474.3
2010 3661 1013 62
1991 3812 1017 12.302
1992 3812 1017 .484
1993 3812 1017 1.617
1994 3812 1017 1.769
1991 3861 1021 -1.187
1992 3861 1021 -.528
1993 3861 1021 -1.256
1994 3861 1021 -4.184
1995 3861 1021 .924
1996 3861 1021 .701
1997 3861 1021 1.549
1998 3861 1021 -3.328
1999 3861 1021 -2.207
2000 3861 1021 -.808
2001 3861 1021 -1.738
2002 3861 1021 .084
2003 3861 1021 -1.515
2004 3861 1021 1.345
2005 3861 1021 1.9
2006 3861 1021 1.005
2007 3861 1021 -4.673
2008 3844 1021 -11.049
1991 3580 1033 .603
1992 3580 1033 -.276
1993 3580 1033 -.374
1991 2834 1034 5.081
1992 2834 1034 16.176
1993 2834 1034 8.621
1994 2834 1034 -2.386
1995 2834 1034 18.817
1996 2834 1034 -11.461
1997 2834 1034 17.408
1998 2834 1034 24.211
1999 2834 1034 36.972
2000 2834 1034 55.508
2001 2834 1034 -37.914
2002 2834 1034 -99.661
2003 2834 1034 13.833
2004 2834 1034 -314.737
2005 2834 1034 133.769
2006 2834 1034 82.544
2007 2834 1034 -13.581
1991 3440 1036 37.01
1992 3440 1036 25.684
1993 3440 1036 39.811
1994 3585 1036 62.143
1995 3585 1036 78.519
1996 3585 1036 94.92
1997 3585 1036 137.978
1998 3443 1036 99.688
1999 3443 1036 88.91
2000 3443 1036 56.55
1991 3663 1037 -.725
1992 3663 1037 -.5
1993 3663 1037 .383
1994 3663 1037 .767
1995 3663 1037 -1.101
1996 3663 1037 -2.761
1997 3663 1037 .937
1998 3663 1037 -3.48
1999 3663 1037 -1.121
2000 3663 1037 1.164
2001 3663 1037 .67
end
[/CODE]
yet due to my lack of knowledge, I failed to interpret kind and detailed replies for my question.
Thus, I decided to elaborate more on my dataset and on the problems I have while devising a code.
My data is a panel data that lists performance of firms for a given year (fyear), within a given industry (sich). Each firm is assigned a unique id (gvkey).
Now, I would like to see how the performance of firms in a specific industry covary across years. High covariance would imply that performance of the firms in the same industry move in the same direction across years (firms all improving or all failing compared to the year before), while low covariance would imply that their performance move rather randomly in terms of direction.
The three issues that remain unsolved while trying to devise a code is as follows.
1. Firm composition for each sich varies for each year. That is, some firms go bankrupt drop out of the industry, while new firms are added to the industry.
2. I want to create a three-year moving window to measure covariance - that is, how performance of firms within a specific industry covary across years t-2, t-1, and t. Yet I do not know how to apply this into my code.
3. I want to create a variable to save the covariance score for each observation. That is, for each firm-year-industry observation, I would to like to calculate the performance covariance measure and save it.
Yet unfamiliar with the stata package (struggling though), I would really appreciate the help from the community. Thank you!
Below is my database:
clear
input int(fyear sich) long gvkey float ni
1991 3460 1009 1.084
1992 3460 1009 2.388
1993 3460 1009 3.362
1994 3460 1009 4.855
1991 3743 1010 156.959
1992 3743 1010 -17.81
1993 3743 1010 112.249
1994 3743 1010 25.2
1995 3743 1010 84.3
1996 3743 1010 92.4
1997 3743 1010 216.4
1998 3743 1010 67.2
1999 3743 1010 77.3
2000 3743 1010 79.9
2001 3743 1010 145.7
2002 3743 1010 79.7
2003 3743 1010 352.5
1991 3661 1013 22.025
1992 3661 1013 21.026
1993 3661 1013 31.636
1994 3661 1013 39.071
1995 3661 1013 55.186
1996 3661 1013 87.463
1997 3661 1013 108.837
1998 3661 1013 146.727
1999 3661 1013 87.635
2000 3661 1013 868.1
2001 3661 1013 -1287.7
2002 3661 1013 -1145
2003 3661 1013 -76.7
2004 3661 1013 16.4
2005 3661 1013 110.7
2006 3661 1013 65.7
2007 3661 1013 106.3
2008 3661 1013 -41.9
2009 3661 1013 -474.3
2010 3661 1013 62
1991 3812 1017 12.302
1992 3812 1017 .484
1993 3812 1017 1.617
1994 3812 1017 1.769
1991 3861 1021 -1.187
1992 3861 1021 -.528
1993 3861 1021 -1.256
1994 3861 1021 -4.184
1995 3861 1021 .924
1996 3861 1021 .701
1997 3861 1021 1.549
1998 3861 1021 -3.328
1999 3861 1021 -2.207
2000 3861 1021 -.808
2001 3861 1021 -1.738
2002 3861 1021 .084
2003 3861 1021 -1.515
2004 3861 1021 1.345
2005 3861 1021 1.9
2006 3861 1021 1.005
2007 3861 1021 -4.673
2008 3844 1021 -11.049
1991 3580 1033 .603
1992 3580 1033 -.276
1993 3580 1033 -.374
1991 2834 1034 5.081
1992 2834 1034 16.176
1993 2834 1034 8.621
1994 2834 1034 -2.386
1995 2834 1034 18.817
1996 2834 1034 -11.461
1997 2834 1034 17.408
1998 2834 1034 24.211
1999 2834 1034 36.972
2000 2834 1034 55.508
2001 2834 1034 -37.914
2002 2834 1034 -99.661
2003 2834 1034 13.833
2004 2834 1034 -314.737
2005 2834 1034 133.769
2006 2834 1034 82.544
2007 2834 1034 -13.581
1991 3440 1036 37.01
1992 3440 1036 25.684
1993 3440 1036 39.811
1994 3585 1036 62.143
1995 3585 1036 78.519
1996 3585 1036 94.92
1997 3585 1036 137.978
1998 3443 1036 99.688
1999 3443 1036 88.91
2000 3443 1036 56.55
1991 3663 1037 -.725
1992 3663 1037 -.5
1993 3663 1037 .383
1994 3663 1037 .767
1995 3663 1037 -1.101
1996 3663 1037 -2.761
1997 3663 1037 .937
1998 3663 1037 -3.48
1999 3663 1037 -1.121
2000 3663 1037 1.164
2001 3663 1037 .67
end
[/CODE]
Comment