I am running correlations for ~3,000 variables. The nuance of the usefulness of p values versus confidence intervals aside, I want to get the p values as a filtering method to include those variables with a p value <0.1 for further evaluation in more complex models. I know that the p value is not stored in the scalars and have read the various hacks to get it to export but cannot seem to get something that works. My code below runs and returns the R2 coefficients, but leaves blank the column for p values. Is there a way to get the p values to export with the correlation values?
Code:
tempfile results
tempname fh
postfile `fh' str32 metabolite rho p using "`results'"
foreach var of varlist pyruvate - methioninesulfoxide {
pwcorr `var' bmi,sig
post `fh' ( "`var''" ) ( r(rho)^2 ) ( r(p) )
}
postclose `fh'
use `results', clear
0 Response to Store and export p values from pwcorr in a loop
Post a Comment