Hi All,
I have data that resembles the following:
In the above, I have data by individuals and year. What I wish to do is to i) Calculate the average of the variable x leaving the contribution of Individual i, for each individual, and year, and ii) Calculating the weight of the other observations in the total sum of the variable x, leaving out variable i's contribution.
Part i) is relatively simple.
However, ii) is more convoluted. This is because each individual will be assigned a different weight in total sum, for every other individual, as each individual has her own specific value of Total, disregarding her contribution. For instance, for 1990, individual 1 will have weight of total output that is different with respect to total output disregarding 2, 3 and 4. Similarly, for 2 and so on. Would the joinby command be appropriate? Any guidance is much appreciated.
Best,
CS
I have data that resembles the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(Individual x Year) 1 32 1990 2 3 1990 3 23 1990 4 3 1990 1 2 1991 2 23 1991 3 2 1991 4 1 1991 end
In the above, I have data by individuals and year. What I wish to do is to i) Calculate the average of the variable x leaving the contribution of Individual i, for each individual, and year, and ii) Calculating the weight of the other observations in the total sum of the variable x, leaving out variable i's contribution.
Part i) is relatively simple.
Code:
by year, egen Total=sum(x) by year Individual, sort: replace Total=Total-x
Best,
CS
Comment