The Book of R by Tilman M. Davies

The Book of R by Tilman M. Davies

Author:Tilman M. Davies
Language: eng
Format: epub, mobi, pdf
Publisher: No Starch Press, Inc.
Published: 2016-08-24T16:00:00+00:00


18.4.1 Single Categorical Variable

Like the Z-test, the one-dimensional chi-squared test is also concerned with comparing proportions but in a setting where there are more than two proportions. A chi-squared test is used when you have k levels (or categories) of a categorical variable and want to hypothesize about their relative frequencies to find out what proportion of n observations fall into each defined category. In the following examples, it must be assumed that the categories are mutually exclusive (in other words, an observation cannot take more than one of the possible categories) and exhaustive (in other words, the k categories cover all possible outcomes).

I’ll illustrate how hypotheses are constructed and introduce the relevant ideas and methods with the following example. Suppose a researcher in sociology is interested in the dispersion of rates of facial hair in men of his local city and whether they are uniformly represented in the male population. He defines a categorical variable with three levels: clean shaven (1), beard only or moustache only (2), and beard and moustache (3). He collects data on 53 randomly selected men and finds the following outcomes:

R> hairy <- c(2,3,2,3,2,1,3,3,2,2,3,2,2,2,3,3,3,2,3,2,2,2,1,3,2,2,2,1,2,2,3,

2,2,2,2,1,2,1,1,1,2,2,2,3,1,2,1,2,1,2,1,3,3)

Now, the research question asks whether the proportions in each category are equally represented. Let π1, π2, and π3 represent the true proportion of men in the city who fall into groups 1, 2, and 3, respectively. You therefore seek to test these hypotheses:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.