BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Abishekaa
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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."

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
sbxkoenk
SAS Super FREQ

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

PGStats
Opal | Level 21

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;

PGStats_0-1629344143122.png

 

PG
Rick_SAS
SAS Super FREQ

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."

Rick_SAS
SAS Super FREQ

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."

Ksharp
Super User
You could use function CORR() in IML . and @Rick_SAS know .

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

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.

Discussion stats
  • 6 replies
  • 1166 views
  • 6 likes
  • 6 in conversation