Hi,
Is there a method in SAS to create bias corrected bootstrap confidence intervals for spearman correlation coefficients?
I tried to follow this blog - Compute a bootstrap confidence interval in SAS - The DO Loop
However, this doesn't seem to work for the proc corr procedure.
Thanks in advance
The OP asked about the Spearman correlation, so change the OUTP= option to the OUTS= option.
The OP asked about a bias-corrected and adjusted confidence interval, whereas my blog post (and PGStat's modification) provides a percentile CI. You can read about ways to obtain a BCa interval in the article "The bias-corrected and accelerated (BCa) bootstrap interval."
However, this doesn't seem to work for the proc corr procedure.
Why not? Seems like it would work as far as I can tell. Use PROC CORR where the example in the blog uses PROC MEANS.
Hello,
> However, this doesn't seem to work for the proc corr procedure.
That is a bit of a vague statement.
Can you tell us why you do conclude that the approach would not work for PROC CORR?
Or do you maybe get errors / warnings in the LOG?
Thanks,
Koen
Rick Wicklin's code can be adapted for proc CORR:
data sample(keep=x y);
set Sashelp.Iris(where=(Species="Virginica") rename=(SepalWidth=x PetalWidth=y));
run;
proc corr data=Sample Pearson;
var x;
with y;
run;
%let NumSamples = 500; /* number of bootstrap resamples */
/* 2. Generate many bootstrap samples */
proc surveyselect data=sample NOPRINT seed=18558
out=BootSetForCorr(rename=(Replicate=SampleID))
method=urs /* resample with replacement */
samprate=1 /* each bootstrap sample has N observations */
/* OUTHITS option to suppress the frequency var */
reps=&NumSamples; /* generate NumSamples bootstrap resamples */
run;
proc corr data=BootSetForCorr outp=BootPearsonCorr(where=(_TYPE_="CORR")) noprint;
by SampleId;
freq NumberHits;
var x;
with y;
run;
proc univariate data=BootPearsonCorr noprint;
var x; /* Variable x in proc CORR output contains the correlation */
output out=BootPctl mean=Boot_Mean_Corr pctlpre =Boot_CI95_
pctlpts = 2.5 97.5 /* compute 95% bootstrap confidence interval */
pctlname=Lower Upper;
run;
proc print data=BootPctl noobs; run;
The OP asked about the Spearman correlation, so change the OUTP= option to the OUTS= option.
The OP asked about a bias-corrected and adjusted confidence interval, whereas my blog post (and PGStat's modification) provides a percentile CI. You can read about ways to obtain a BCa interval in the article "The bias-corrected and accelerated (BCa) bootstrap interval."
I should mention that you will need an extra step if you want to bootstrap the correlation among more than two variables. In PGStat's program, the program works for a single correlation coefficient. However, when bootstrapping k > 2 variables, the OUTP= data set puts the correlation coefficients into a matrix. You then need to use an extra step to prepare the bootstrap distribution for analysis. For details and an example, see "Bootstrap correlation coefficients in SAS."
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.