The script analyzes movie ratings from Siskel and Ebert. Initially, the data is created and formatted. Then, a simple concordance analysis is performed with PROC FREQ to obtain Cohen's Kappa. Subsequently, the data is transformed using PROC IML for use in PROC NLMIXED, which estimates Kappa through a customized likelihood model. The results from both NLMIXED approaches (via the ESTIMATE statement and by manual parameter transformation) are then displayed and compared.
Data Analysis
Type : CREATION_INTERNE
The main dataset 'movie_ratings' is created directly in the code using a 'datalines' statement. Subsequent datasets are derived from this initial table.
1 Code Block
DATA STEP Data
Explanation : This block creates the 'movie_ratings' dataset. It reads 3 columns (x1-x3) and transforms the table structure to obtain a long format where each row represents a Siskel/Ebert rating combination with a weight 'w'.
Explanation : Uses PROC FREQ to generate a contingency table between Siskel's and Ebert's ratings. The '/agree' option requests the calculation of concordance statistics, including the Kappa coefficient. The variable 'w' is used as a weight.
Copied!
ods html;
title1 "Siskel's and Ebert's Movie Ratings -- Agresti and Winner (1997)";
title2 "Kappa Results using PROC FREQ";
proc freq data=movie_ratings;
tables Siskel * Ebert / agree;
weight w;
format Siskel Ebert abc.;
run;
ods graphics off;
ods html close;
1
ods html;
2
title1 "Siskel's and Ebert's Movie Ratings -- Agresti and Winner (1997)";
3
title2 "Kappa Results using PROC FREQ";
4
PROC FREQDATA=movie_ratings;
5
tables Siskel * Ebert / agree;
6
weight w;
7
FORMAT Siskel Ebert abc.;
8
RUN;
9
ods graphics off;
10
ods html close;
4 Code Block
PROC IML Data
Explanation : This PROC IML block reads the data and transforms it into a matrix 't' for modeling with NLMIXED. It prepares the data to model the joint distribution of ratings. The result is stored in the 'new' table.
Copied!
ods html;
ods graphics on;
proc iml;
use movie_ratings;
read all into x;
n0 = nrow(x);
n1 = sum(x[,3]);
t1 = j(n1,3,0);
t2 = j(n1,3,0);
row = 0;
do j=1 to n0;
do t=1 to x[j,3];
row = row + 1;
t1[row,x[j,1]] = 1;
t2[row,x[j,2]] = 1;
end;
end;
t = t1 + t2;
create new var{t1 t2 t3};
append from t;
quit;
1
ods html;
2
ods graphics on;
3
PROC IML;
4
use movie_ratings;
5
read all into x;
6
7
n0 = nrow(x);
8
n1 = sum(x[,3]);
9
t1 = j(n1,3,0);
10
t2 = j(n1,3,0);
11
12
row = 0;
13
DO j=1 to n0;
14
DO t=1 to x[j,3];
15
row = row + 1;
16
t1[row,x[j,1]] = 1;
17
t2[row,x[j,2]] = 1;
18
END;
19
END;
20
21
t = t1 + t2;
22
create new var{t1 t2 t3};
23
append from t;
24
QUIT;
5 Code Block
PROC NLMIXED Data
Explanation : Fits a nonlinear model using a general log-likelihood function (loglik) to estimate model parameters, including 'a0' which is related to Kappa. The 'estimate' statement directly calculates Kappa and its confidence interval. Results are saved in 'Parms_Estimates' and 'Estimates' tables.
Explanation : These two data steps modify the PROC NLMIXED result tables. The first simply renames a column. The second applies an inverse transformation to the 'a0' parameter and its confidence bounds to manually calculate Kappa.
Explanation : Displays the two final tables containing Kappa estimates obtained by the two calculation methods from PROC NLMIXED.
Copied!
title2 "Kappa Results using the Estimate Statement in NLMIXED";
proc print data=Estimates noobs;
run;
title2 "Kappa Results using the Inverse Method in NLMIXED";
proc print data=Parms_Estimates noobs;
run;
ods html close;
1
title2 "Kappa Results using the Estimate Statement in NLMIXED";
2
PROC PRINTDATA=Estimates noobs;
3
RUN;
4
5
title2 "Kappa Results using the Inverse Method in NLMIXED";
6
PROC PRINTDATA=Parms_Estimates noobs;
7
RUN;
8
ods html close;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.