I want to calculate bootstrapped standard error (and pvalue) of the difference between two correlation coefficients.
In my context, the two correlation coefficients are calculated on two separate samples. In other words, I am essentially comparing correlations between groups.
I plan to use rhsbsample to generate bootstrap replicate weights because I need to incorporate sampling weight in analysis.
Below is my code. Unfortunately, it does not work well. In the end, it alerts me that "last estimates not found". Can someone offer help? Thank you!
rhsbsample is written by Van Kerm's (2013) (available from the SSC archive).
Van Kerm, P. 2013. rhsbsample: Stata module for repeated half-sample bootstrap sampling. Statistical Software Components S457697, Department of Economics, Boston College. https://ideas.repec.org/c/boc/bocode/s457697.html.
Part of my code come from Jenkins, Stephen P. 2020. “Comparing Distributions of Ordinal Data.” The Stata Journal 20(3):505–31. doi: 10.1177/1536867X20953565, and a prior thread on Statalist.
Code:
webuse nlsw88,clear rename ttl_exp pweight //create artificial sampling weight variable capture prog drop corrdiff program define corrdiff, rclass corr wage hours if south==0 local def1=`r(rho)' corr wage hours if south==1 local def2=`r(rho)' return scalar diff = `def2' - `def1' end local R = 100 forvalues i = 1/`R' { qui gen rhsbrw`i' = . qui rhsbsample, weight(rhsbrw`i') strata(south) qui replace rhsbrw`i' = rhsbrw`i' * pweight } svyset [pw = pweight], vce(bootstrap) bsrweight(rhsbrw*) mse svy bootstrap diff = (r(diff)), dots: corrdiff
0 Response to error using svy bootstrap with self-written program
Post a Comment