ANALYSIS OF CATEGORICAL DATA, WHEN THE DATA ARE DEPENDENT

ANALYSIS OF CATEGORICAL DATA, WHEN THE DATA ARE DEPENDENT

To compare proportions between two groups or to test for independence between two categorical variables we use the Chi-square test .But when the categorical data are paired Mcnemar test is the appropriate one. The Basic McNemar test applies to a 2*2 contingency table with the dichotomous variable at time 1 and time 2.

If we want to determine whether or not, a particular drug has an effect on a disease, then a count of the individuals is recorded (as positive/negative, or 0 and 1) in a table before and after being given the drug.

Considered 155 subjects and recorded their response on particular disease before and after the treatment. The 82 subjects who had no disease (negative) at both time point and 23 subjects who had disease (positive) at both time points are irrelevant to this comparison. We are actually interested in the change in subjects’ response. Cell b, c is represented pairs with difference.

The McNemar’s Chi-square statistic is calculated using the counts in the ‘b’ and ‘c’ cells of the table:
χ2 = 2(b-c) / (b+c)
To determine whether a drug has an effect on the disease, the result of diagnosis before and after the treatment is tabulated on a 2×2 contingency table

After : Disease Negative After : Disease PositiveTotal
Before : Disease Negative82 (a)11 (b)93
Before : Disease Positive39 (c)23 (d)62
Total12134155

The null hypothesis of the Mcnemar test indicates that the drug has same effect on disease before – after treatments.

How to do Mcnemar’s test in SAS

Consider the above example

To do Mcnemar in SAS use PROC FREQ procedure. McNemar’s test is requested by including the AGREE option on the TABLES statement. The EXPECTED option displays the expected cell frequencies under the hypothesis of independence (or homogeneity).The printing of the percent, column percent and row percent in each cell can be suppressed by specifying the NOPERCENT, NOCOL and NOROW options on the TABLES statement. A kappa statistic can determine the level of agreement in these responses.

proc format;
value res 1 =’Positive’
0 =’Negative';
run;
data Mcn;
input before after count;
format before after $res.;
datalines;
0 0 82
0 1 11
1 1 23
1 0 39
;
proc freq data=Mcn order = data;
tables before*after/agree expected norow nocol nopercent;
weight count;
run;

The output table is as follows:

mcnemar1

Then the test statistic is 15.6800 and the 2-tails p-values <.001.Therefore the null hypothesis is rejected with 1% significance level. Thus we conclude that drug has an effect on the disease.

Post A Comment

Protected by WP Anti Spam