********************************************* * LIN'S CONCORDANCE CORRELATION COEFFICIENT * ********************************************* * (c) Marta Garcia-Granero (08/2005) * * Updated (04/2009): square graph with y=x * * mgarciagranero@gmail.com * * Downloaded from: http://gjyp.nl/marta/ * * Feel free to use or modify this code, but * * acknowledge the author and the web site * ********************************************* DESCRIPTION Lin's concordance correlation coefficient measures how well a new set of observations reproduce an original set. So, for example, it can be used to assess the effectiveness of new instruments or measurement methods. The coefficient is calculated by multiplying two components. The first is the ordinary Pearson correlation coefficient, which essentially assesses the linear relationship between the two sets of measurements. However, for the second set to reproduce the first, the slope of the line relating the two sets should be one, and the line should go through the origin. These other aspects are assessed by the second component, which is known as Cb. METHOD The coefficient Rc is derived by Lin (1989) by considering how well the relationship between the measurements is represented by a line through the origin at an angle of 45 degrees (as would be generated if the two measurements generated identical results): Rc = 1 - dc²/du² where dc² is the expected squared perpendicular deviation from the line, and du² is the expected squared perpendicular deviation from the line when the measurements are uncorrelated. This can be written as Rc = R × Cb The term R is the standard Pearson product-moment correlation coefficient, while Cb is a bias correction factor which is calculated by Cb = 2 / (v + 1/v + u²) v = s1/ s2 u = (m1 - m2) / SQRT(s1 × s2) --> 'Mean shift' where mi and si (i = 1,2) are the mean and standard deviation of the ith set of measurements. The Z-transformation (Fisher) is Z = 0.5 × (log(1 + Rc)/(1 - Rc)) The standard deviation of the Z-transformed coefficient is calculated as defined by Lin (2000). See formula 31 & 32 in: "Assessment of the Adequacy of Mathematical Models", by Luis Orlindo Tedeschi. SCALE 0.21–0.40 Fair 0.41–0.60 Moderate 0.61–0.80 Substantial 0.81–1.00 Almost perfect REFERENCES - Lin, L.I. (1989). A concordance correlation coefficient to evaluate reproducibility. Biometrics, 45, 255-268. - Lin, L.I. (2000). A note on the concordance correlation coefficient. Biometrics, 56, 324-325. - Tedeschi, L.O. 2006. Assessment of the adequacy of mathematical models. Agric. Syst. 89:225-247. * BEGINNING OF SYNTAX *. DEFINE LINCCC(!POS=!TOKENS(1)/!POS=!TOKENS(1)). DATASET NAME OriginalData. DATASET DECLARE Results WINDOW=HIDDEN. MATRIX. PRINT /TITLE="Lin's Concordance Coefficient". GET pair /VARIABLES=!1 !2 /NAMES=vname /MISSING OMIT. COMPUTE n=NROW(pair). COMPUTE mean=CSUM(pair)/n. COMPUTE variance=(CSSQ(pair)-n*mean&**2)/(n-1). COMPUTE Minval=0.9*MMIN(pair). COMPUTE Maxval=1.1*MMAX(pair). PRINT {mean;variance} /TITLE='X & Y Statistics' /FORMAT='F8.3' /RLABELS='Mean','Variance' /CNAMES=vname. PRINT n /TITLE='Nr. of valid pairs' /FORMAT='F8.0'. COMPUTE covxy=((T(pair(:,1))*pair(:,2))-n*mean(1)*mean(2))/(n-1). COMPUTE r=covxy/SQRT(variance(1)*variance(2)). COMPUTE ncovxy=covxy*(n-1)/n. COMPUTE nvarx=variance(1)*(n-1)/n. COMPUTE nvary=variance(2)*(n-1)/n. COMPUTE sdx=SQRT(nvarx). COMPUTE sdy=SQRT(nvary). COMPUTE lcc=2*ncovxy/(nvarx+nvary+(mean(1)-mean(2))**2). COMPUTE cb=lcc/r. COMPUTE zr=.5*LN((1+lcc)/(1-lcc)). COMPUTE u=((n-1)/n)*(mean(1)-mean(2))/(SQRT(sdx*sdy)). COMPUTE u2=u**2. COMPUTE u4=u**4. COMPUTE r2=r**2. COMPUTE rc2=lcc**2. COMPUTE rc3=lcc**3. COMPUTE rc4=lcc**4. COMPUTE term1=((1-r2)*rc2)/((1-rc2)*r2). COMPUTE term2=(2*(rc3-rc4)*u2)/(r*((1-rc2)**2)). COMPUTE term3=(rc4*u4)/(2*r2*((1-rc2)**2)). COMPUTE sezr=SQRT((term1+term2-term3)/(n-2)). COMPUTE lowz1=zr-1.645*sezr. COMPUTE lowzr=zr-1.959964*sezr. COMPUTE uppzr=zr+1.959964*sezr. COMPUTE lowr1=((exp(2*lowz1))-1)/((exp(2*lowz1))+1). COMPUTE lowr=((exp(2*lowzr))-1)/((exp(2*lowzr))+1). COMPUTE uppr=((exp(2*uppzr))-1)/((exp(2*uppzr))+1). PRINT {covxy,r} /TITLE='Association statistics' /FORMAT='F8.4' /CLABELS="Cov.","R". PRINT {lcc,cb,ABS(u)} /TITLE="Lin's Concordance Coefficient & related statistics" /CLABELS='Rc','Cb','Mn.Shift' /FORMAT='F8.3'. PRINT {lowr,uppr} /FORMAT='F8.3' /CLABELS='Lower' 'Upper' /TITLE='95%CI for Rc'. PRINT lowr1 /FORMAT='F8.3' /TITLE='Lower one-sided 95% CL for Rc'. PRINT {zr,sezr} /FORMAT='F8.3' /CLABEL='Z','SE(Z)' /TITLE='Fisher transformation:'. SAVE {Minval,Maxval} /OUTFILE=Results. END MATRIX. DATASET ACTIVATE Results. PRESERVE. SET LOCALE=ENGLISH. STRING #var1 #var2 (A12). DO REPEAT A=#var1 #var2 /B=col1 col2. - COMPUTE A = STRING(B,E11.3). END REPEAT. !LET !minval=!UNQUOTE(#var1). !LET !maxval=!UNQUOTE(#var2). * Write Template to Temp *. WRITE OUTFILE 'C:\Temp\LinTemplate.sgt' /'' /'