2008年6月23日 星期一

Reliability analysis: Calculate and Compare Intra-class Correlation Coefficients (ICC) in SAS

原文載點:http://www.nesug.info/Proceedings/nesug07/sa/sa13.pdf

在 reliability analysis 裡面,intra-class correlation coefficients (ICC) 是一個相當重要的統計指標。不過長久以來,SAS 內部並沒有可以直接計算 ICC 的程序。雖然有許多線上的 ICC 計算器,不過仍有許多人研發出在 SAS 上運作的 ICC macro 供 SAS 使用者使用。Li Lu 和 Nawar Shara 在 2007 年的 NESUG 發表了一篇自行撰寫的 ICC macro 技術文件,不但可用來計算 ICC 本身,還可以求出其信賴區間。

原始碼如下:
%macro Icc_sas(ds, response, subject);
ods output OverallANOVA =all;
proc glm data=&ds;
class &subject;
model &response=&subject;
run;
data Icc(keep=sb sw n R R_low R_up);
retain sb sw n;
set all end=last;
if source='Model' then sb=ms;
if source='Error' then do;sw=ms; n=df; end;
if last then do;
R=round((sb-sw)/(sb+sw), 0.01);
vR1=((1-R)**2)/2;
vR2=(((1+R)**2)/n +((1-R)*(1+3*R)+4*(R**2))/(n-1));
VR=VR1*VR2;
L=(0.5*log((1+R)/(1-R)))-(1.96*sqrt(VR))/((1+R)*(1-R));
U=(0.5*log((1+R)/(1-R)))+(1.96*sqrt(VR))/((1+R)*(1-R));
R_Low=(exp(2*L)-1)/(exp(2*L)+1);
R_Up=(exp(2*U)-1)/(exp(2*U)+1);
output;
end;
run;
proc print data=icc noobs split='*';
var r r_low r_up;
label r='ICC*' r_low='Lower bound*' r_up='Upper bound*';
title 'Reliability test: ICC and its confidence limits';
run;
%mend;

包含三個參數:
  • ds:資料名稱(含 library)
  • response:反應變數名稱
  • subject:ID 名稱
使用方式相當簡單。如:
%Icc_sas(ds=one, response=cimt, subject=subject_id);

由於原文沒有提供 one 這個資料集的原始資料,所以不知道跑出來的結果如何。有興趣的人可以拿自己的資料測試,並與其他線上 ICC 計算器的結果進行比對。如有發現異常現象請回報給原作者。

CONTACT INFORMATION
Your code requests, comments and questions are valued and encouraged. Contact the author at
Li Lu
Dept of Epidemiology and Statistics
MedStar Research Institute
6495 New Hampshire Avenue
Hyattsville, MD 20783
(301) 560-7313
li.lu@medstar.net

沒有留言:

張貼留言

要問問題的人請在文章下方的intensedebate欄位留言,請勿使用blogger預設的意見表單。今後用blogger意見表單留言的人我就不回應了。