Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65037

Egen calculation, means/sd

$
0
0
Hi everyone,

I'm trying to manually calculate a value for each household in a survey. Using three dummy variables in the dataset (X, Y, Z), I'd like to generate a new variable that takes on the following value for each household:

Code:
egen index = 0.02*((X-mean(X))/sd(X)) + 0.05*((Y-mean(Y))/sd(Y)) + 0.04*((Z-mean(Z))/sd(Z))
where 0.02, 0.05, and 0.04 are constants I've defined; X, Y, and Z are either 0 or 1, depending on the household; and the means and standard deviation should be the weighted ones obtained using sum with analytic weights:

Code:
summarize X Y Z [aw=wgt]
However, the egen code returns "unknown function" errors.

Thank you.


EDIT:

As an aside, the reason that I’m doing this is because I used factor analysis on an older dataset to calculate the first principal components (which are the 0.02, 0.05, and 0.04).

I'm now trying to caculate index scores (which is the equation above) for households in a more recent survey, but using the principal components I obtained for the older survey. In the older survey I simply used the "predict" function after having run the PCA analysis to calculate the scores.

Please let me know if there is an easier solution to this problem. I'm trying to avoid having to merge the two files, which would be a bit tedious given how differently the datasets are organized.

Viewing all articles
Browse latest Browse all 65037

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>