Dear Statalisters,
I am trying to calculate Pearson's correlations for 2 Variables in a dataset with M=10 imputations.
Since the pwcorr command is not supported by the mi command in Stata, I searched for an alternative and found out that I can combine the correlations coefficients using Fisher's z transformation.
Following the example for combining R^2 (http://www.stata.com/support/faqs/st...-imputed-data/), I tried the following command:
mi query
local M=10
scalar corr=0
mi xeq 1/`M' : pwcorr v1 v2 scalar corr = corr + atanh(sqrt(e(corr)))
scalar corr = tanh(corr/`M')^2
di as txt "Correlation using Fisher's z over imputed data = " as res corr
However, even though Stata is calculating the individual correlations for each m it does not show anything when it comes to the final result. All I get is
. scalar corr = tanh(corr/`M')^2
. di as txt "Korrelation using Fisher's z over imputed data = " as res corr
Korrelation using Fisher's z over imputed data = .
I am not an expert on doing these kind of calculations in Stata and think that maybe the formula from the R^2 example can not be used for correlations, but I am lost on who to adapt it in order to get it to work.
Any help would be greatly appreciated,
Maleika
I am trying to calculate Pearson's correlations for 2 Variables in a dataset with M=10 imputations.
Since the pwcorr command is not supported by the mi command in Stata, I searched for an alternative and found out that I can combine the correlations coefficients using Fisher's z transformation.
Following the example for combining R^2 (http://www.stata.com/support/faqs/st...-imputed-data/), I tried the following command:
mi query
local M=10
scalar corr=0
mi xeq 1/`M' : pwcorr v1 v2 scalar corr = corr + atanh(sqrt(e(corr)))
scalar corr = tanh(corr/`M')^2
di as txt "Correlation using Fisher's z over imputed data = " as res corr
However, even though Stata is calculating the individual correlations for each m it does not show anything when it comes to the final result. All I get is
. scalar corr = tanh(corr/`M')^2
. di as txt "Korrelation using Fisher's z over imputed data = " as res corr
Korrelation using Fisher's z over imputed data = .
I am not an expert on doing these kind of calculations in Stata and think that maybe the formula from the R^2 example can not be used for correlations, but I am lost on who to adapt it in order to get it to work.
Any help would be greatly appreciated,
Maleika
Comment