/**************** Polarity Analysis ***************** Author: William Chambers, PhD Experior Assessments Gainesville, Florida 1-800-888-8421 ext 361 Date: 17 Aug 2000 This code is provided gratis, without warrantee. This code is licensed at no charge to all third parties, but proprietary modifications of the code are not allowed. *********************************************************/ /* this program calculates the polarity score in corresponding correlations */ format /m1 /rd 6,2; n=100; /*define variables and causal model*/ x1=rndu(n,1); zx1=((x1-meanc(x1))./stdc(x1)); x2=rndu(n,1); zx2=(x2-meanc(x2))./stdc(x2); y1=(zx1+zx2); zy1=(y1-meanc(y1))./stdc(y1); /* The Causal Model */ x=zx1~zx2~zy1; /* Measured Variables */ /* creates extremes/mid ranges by hypothesized DV (third variable)*/ nr=rows(x); lo=seqa(1,1,nr./4); hi=seqa((3.*(nr./4))+1,1,nr./4); ext=lo|hi; mid=seqa(((nr./4))+1,1,nr./2); /****** Sort Here **********/ xby=sortc(x,3); /*sort by third measured variable */ /***************************/ /***** partition into extremes and midranges */ exy=submat(xby,ext,0); /*extremes of dv */ midy=submat(xby,mid,0); /* midrange of dv */ /* finds correlation between 1st and 2nd variables in the extremes of third*/ cexy= corrx(exy); /*sexy=(cexy./abs(cexy)).*(cexy.*cexy);*/ /*correlations between first two (x1 and x2) in the midrange of third (y) */ cmidy= corrx(midy); /*semidy=(cmidy./abs(cmidy)).*(cmidy.*cmidy); */ result=cexy~cmidy; pol1=submat(result(1,3)); pol2=submat(result(1,5)); polar=((pol1.*pol1).*(pol1./abs(pol1))).*((pol2.*pol2).*(pol2./abs(pol2))); pols=pol1~pol2~polar; print; print "Polarity Analysis for Corresponding Correlations "; print; print "Correlations between 1st and 2nd variables across ranges of 3rd variable"; print; print" Ext3 Mid3 Polarity"; print ; print " " pols;