jacob-long / jtools

Tools for summarizing/visualizing regressions and other helpful stuff
https://jtools.jacob-long.com
GNU General Public License v3.0
163 stars 22 forks source link

error in calculation of bootstrapped SE in pf_sv_test() #89

Closed randridge closed 2 years ago

randridge commented 4 years ago

Hi Jacob, I have a student using your weight test functions for a project (thank you for providing these) and have discovered what I think is an error in the pv_sv_test() code. Specifically, in the calculation of the bootstrapped SD for the correlations.

The bootstrapping uses the function corfun() [defined inside the pf_sv_test() code], and this function returns the transformed correlations:

return(c(atanh(c1), atanh(c2), atanh(c3)))

But then when the SD is calculated on the bootstrapped correlations, it appears that the Fisher's transformation happens again:

Getting the bootstrapped SD of the correlation, but transforming to # Fisher's Z first

sd1 <- sd(atanh(bo$t[,1])) sd2 <- sd(atanh(bo$t[,2])) sd3 <- sd(atanh(bo$t[,3]))

I think those atanh() calls should be removed in the calculation of the SDs. (Or, change corfun() so that it returns the untransformed correlations.)

Thanks, -Rebecca

jacob-long commented 2 years ago

Wow, great catch! Thanks so much for letting me know. This will be fixed for the next release.