Hi,
I have a rather trivial question but it's been bugging me for days. So I'd appreaciate some tehnical help from this forum.
I'm working on a panel dataset comprising 3,168 firms from 47 countries for 7 years (2012-2108).
Using this dataset, I want to capture the relative positioning of a country based on an institutional characteristic (say X), so for this purpose I calculate the Z-score of institutional variable X.
The idea is that countries with positive and larger Z-score (closer to 1) would be the representative of the institutional characteristics.
(For interested readers, what I do is similar to the standardized institutional variable in Gupta et al. (2020)) https://sms.onlinelibrary.wiley.com/....1002/smj.3204
I calculate the Z-score using the following code
I also do it manually by calculating the mean and standard deviation of variable X for each year
To my surprise, the mean and standard deviation produced by Stata is substantially larger, and thereby the Z-score would be incorrect. Here I give one example for year 2013.
N is the number of firm observations in a country. SD for individual country is zero because the value of institutional variable X is the same for every firms in the same country.
With manual calculation, the mean should be 0.708317 and standard deviation 0.120099.
I don't think the difference is mainly driven by rounds up. Would appreaciate any enlighment on this issue. Thanks!
I have a rather trivial question but it's been bugging me for days. So I'd appreaciate some tehnical help from this forum.
I'm working on a panel dataset comprising 3,168 firms from 47 countries for 7 years (2012-2108).
Using this dataset, I want to capture the relative positioning of a country based on an institutional characteristic (say X), so for this purpose I calculate the Z-score of institutional variable X.
The idea is that countries with positive and larger Z-score (closer to 1) would be the representative of the institutional characteristics.
(For interested readers, what I do is similar to the standardized institutional variable in Gupta et al. (2020)) https://sms.onlinelibrary.wiley.com/....1002/smj.3204
I calculate the Z-score using the following code
Code:
bys year: egen z_institutionX = std(institutionX)
Code:
bys year: egen mean_institutionX = mean(institutionX)
Code:
bys year: egen sd_institutionX = sd(institutionX)
Code:
bys year: gen manualz_institutionX = (institutionX - mean_institutionX)/sd_institutionX
N is the number of firm observations in a country. SD for individual country is zero because the value of institutional variable X is the same for every firms in the same country.
With manual calculation, the mean should be 0.708317 and standard deviation 0.120099.
I don't think the difference is mainly driven by rounds up. Would appreaciate any enlighment on this issue. Thanks!
Code:
hq N Mean SD Australia 138 .8116238 0 Austria 12 .5283403 0 Belgium 14 .4955547 0 Denmark 18 .5816855 0 Finland 22 .6569287 0 Germany 63 .6950699 0 Japan 314 .7472216 0 Netherlands 28 .7077156 0 Norway 12 .7062369 0 Sweden 28 .7839157 0 Switzerland 54 .860143 0 United Kingdom 178 .7391919 0 United States 500 .8944967 0 Total 1381 .7995181 .0882503

Comment