06.09.2021 Views

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

subj.1 : 1 no :70 no :90<br />

subj.10 : 1 yes:30 yes:10<br />

subj.100: 1<br />

subj.11 : 1<br />

subj.12 : 1<br />

subj.13 : 1<br />

(Other) :94<br />

Notice that each participant appears only once in this data frame. When we tabulate this data frame<br />

using xtabs(), we get the appropriate table:<br />

> right.table print( right.table )<br />

response_after<br />

response_be<strong>for</strong>e no yes<br />

no 65 5<br />

yes 25 5<br />

<strong>and</strong> from there, we can run the McNemar test by using the mcnemar.test() function:<br />

> mcnemar.test( right.table )<br />

McNemar’s Chi-squared test <strong>with</strong> continuity correction<br />

data: right.table<br />

McNemar’s chi-squared = 12.0333, df = 1, p-value = 0.0005226<br />

And we’re done. We’ve just run a McNemar’s test to determine if people were just as likely to vote AGPP<br />

aftertheadsastheywerebe<strong>for</strong>eh<strong>and</strong>. Thetestwassignificant(χ 2 p1q “12.04,p ă .001), suggesting<br />

that they were not. And in fact, it looks like the ads had a negative effect: people were less likely to<br />

vote AGPP after seeing the ads. Which makes a lot of sense when you consider the quality of a typical<br />

political advertisement.<br />

12.9<br />

What’s the difference between McNemar <strong>and</strong> independence?<br />

Let’s go all the way back to the beginning of the chapter, <strong>and</strong> look at the cards data set again. If you<br />

recall, the actual experimental design that I described involved people making two choices. Because we<br />

have in<strong>for</strong>mation about the first choice <strong>and</strong> the second choice that everyone made, we can construct the<br />

following contingency table that cross-tabulates the first choice against the second choice.<br />

> cardChoices cardChoices<br />

choice_2<br />

choice_1 clubs diamonds hearts spades<br />

clubs 10 9 10 6<br />

diamonds 20 4 13 14<br />

hearts 20 18 3 23<br />

spades 18 13 15 4<br />

Suppose I wanted to know whether the choice you make the second time is dependent on the choice you<br />

made the first time. This is where a test of independence is useful, <strong>and</strong> what we’re trying to do is see if<br />

there’s some relationship between the rows <strong>and</strong> columns of this table. Here’s the result:<br />

- 377 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!