BookmarkSubscribeRSS Feed
blueskyxyz
Lapis Lazuli | Level 10
data FatComp;
         input Test Response Count;
         datalines;
1 1  130
1 0  20
0 1  40
0 0  160
;
/*******************************************************************************************
** kappa 
*******************************************************************************************/

data kappa1;
	a=130; b=20; c=40; d=160;
	p0=(a+d)/(a+b+c+d);
	pe=((a+b)*(a+c)+(d+b)*(d+c))/(a+b+c+d)**2;
	se=sqrt((p0*(1-p0)/(1-pe)**2)/(a+b+c+d));
	kappa=(p0-pe)/(1-pe);

	z=PROBIT(1-0.05/2);
	kappa_low=kappa-z*se;
	kappa_high=kappa+z*se;
run;



/*ods trace on;*/
ods output KappaStatistics=Kappa2;
proc freq data=FatComp;
	weight count/zeros;
	tables Test*Response/agree;
/*	test kappa wtkap;*/
/*	exact kappa ;*/
run; 
/*ods trace off;*/

blueskyxyz_0-1667961482723.png

 

hi sasusers,

 

please take a look at my code to calculate kappa,  the CI value is a little bit different between kappa1 and kappa2 while the estimate is almost same, so how to modify the code ( get the simple kappa in data step with the formula) to have the same result.

 

use two methods to double qc the kappa, I want get a 100% equal compare report, BTW, how to get the weight kappa using proc freq in SAS9.4.

 

Thanks.

Sky.

 

 

2 REPLIES 2
blueskyxyz
Lapis Lazuli | Level 10
/*test data*/
data FatComp; input Test Response Count; datalines; 1 1 130 1 0 20 0 1 40 0 0 160 ; /******************************************************************************************* ** kappa *******************************************************************************************/ data kappa1; a=130; b=20; c=40; d=160; p0=(a+d)/(a+b+c+d); pe=((a+b)*(a+c)+(d+b)*(d+c))/(a+b+c+d)**2; se=sqrt((p0*(1-p0)/(1-pe)**2)/(a+b+c+d)); kappa=(p0-pe)/(1-pe); z=PROBIT(1-0.05/2); kappa_low=kappa-z*se; kappa_high=kappa+z*se; run; /*ods trace on;*/ ods output KappaStatistics=Kappa2; proc freq data=FatComp; weight count/zeros; tables Test*Response/agree; /* test kappa wtkap;*/ /* exact kappa ;*/ run; /*ods trace off;*/

blueskyxyz_0-1667961482723.png

 

hi sasusers,

 

please take a look at my code to calculate kappa,  the CI value is a little bit different between kappa1 and kappa2 while the estimate is almost same, so how to modify the code ( get the simple kappa in data step with the formula) to have the same result.

 

use two methods to double qc the kappa, I want get a 100% equal compare report, BTW, how to get the weight kappa using proc freq in SAS9.4.

 

Thanks.

Sky.

 

 

blueskyxyz
Lapis Lazuli | Level 10
the formula is not right, will update later

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 1081 views
  • 0 likes
  • 1 in conversation