BookmarkSubscribeRSS Feed
jrbrauer
Fluorite | Level 6
Hi all,

I cannot seem to figure out the code to create a combined correlation matrix from several imputed datasets.

I have used Proc Corr to output a datafile with the correlation matrices from 5 imputed datasets using the code below. However, I cannot seem to figure out the Proc Mianalyze code to output the combined matrix - the latter code just produces combined means and standard errors. Does anyone know how to combine and output the correlation matrix?

* output stacked dataset with correlation matrices for each imputed dataset;
proc corr data=temp out = outcorr;
var x1 x2 x3 x4 ;
by _imputation_;
run;

*combine results using proc mianalyze;
proc mianalyze data=outcorr ;
modeleffects x1 x2 x3 x4;
run;

Thank you for your time and any help you can offer!
Jon
3 REPLIES 3
jrbrauer
Fluorite | Level 6
A member of SAS technical support provided me with an answer to this query. I am posting the code below in case this helps anyone else...


* Below is a sample program that shows how to get a combined correlation matrix using MIANALYZE ;

data FitMiss;
input Oxygen RunTime RunPulse @@;
x=rannor(412432)*oxygen;
datalines;
44.609 11.37 178 45.313 10.07 185
54.297 8.65 156 59.571 . .
49.874 9.22 . 44.811 11.63 176
. 11.95 176 . 10.85 .
39.442 13.08 174 60.055 8.63 170
50.541 . . 37.388 14.03 186
44.754 11.12 176 47.273 . .
51.855 10.33 166 49.156 8.95 180
40.836 10.95 168 46.672 10.00 .
46.774 10.25 . 50.388 10.08 168
39.407 12.63 174 46.080 11.17 156
45.441 9.63 164 . 8.92 .
45.118 11.08 . 39.203 12.88 168
45.790 10.47 186 50.545 9.93 148
48.673 9.40 186 47.920 11.50 170
47.467 10.50 170
;

proc mi data=FitMiss seed=3237851 noprint out=outmi;
var Oxygen RunTime RunPulse x;
run;

proc corr data=outmi fisher(biasadj=no);
var Oxygen RunTime runpulse x;
by _Imputation_;
ods output FisherPearsonCorr= outz;
run;


data outz;
set outz;
StdZ= 1. / sqrt(NObs-3);
pair=trim(left(var))||trim(left(withvar));
run;
proc sort data=outz;
by pair _imputation_;
run;

proc mianalyze data=outz;
by pair;
ods output ParameterEstimates=parms;
modeleffects ZVal;
stderr StdZ;
run;
data corr_ci;
set parms;
label r='Correlation Coefficient';
r=tanh( Estimate);
run;
proc print data=corr_ci label;
run;
SandraG
Calcite | Level 5

This is an amazing help. I am having the same issue but with polychoric correlation matrices.

 

I have 5 imputed datasets (outMI), and I have the following code to compute polychoric correlation matrices from the 5 imputed datasets (to create dataset polycorr_MI):

proc corr data=outMI outplc=polycorr_MI (TYPE=CORR);
var x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15;
by _IMPUTATION_;
run;

 

Is there a similiar way to do this combination when you have polychoric and not pearson correlations?

FreelanceReinh
Jade | Level 19

Hello @SandraG and welcome to the SAS Support Communities!

 

Only a few people will notice that you have replied to this almost ten year old thread. Notifications are sent to the participants of the old discussion, i.e., to only one person in this case -- whose last visit to the SAS Support Communities was in 2017 (according to jrbrauer's user profile). I suggest that you start a new thread, not in the SAS Procedures subforum, but under Statistical Procedures (use the orange "Start A Topic" button there). Then it'll be much more likely that one of the SAS/STAT experts will reply to your question. You can provide a link to jrbrauer's post as a reference: https://communities.sas.com/t5/SAS-Procedures/Producing-a-combined-correlation-matrix-using-PROC-MIA...

Good luck!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1488 views
  • 1 like
  • 3 in conversation