0% found this document useful (0 votes)
4 views12 pages

Assignment 4

The document provides a detailed overview of categorical data analysis, focusing on the relationship between statistics and heredity, particularly in genetics. It explains the chi-square test, including its types (goodness of fit, independence, and homogeneity), and outlines the steps for performing these tests with examples. Additionally, it discusses the chi-square test for 2x2 contingency tables, emphasizing its application in assessing associations between categorical variables.

Uploaded by

Lightning Hacker
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views12 pages

Assignment 4

The document provides a detailed overview of categorical data analysis, focusing on the relationship between statistics and heredity, particularly in genetics. It explains the chi-square test, including its types (goodness of fit, independence, and homogeneity), and outlines the steps for performing these tests with examples. Additionally, it discusses the chi-square test for 2x2 contingency tables, emphasizing its application in assessing associations between categorical variables.

Uploaded by

Lightning Hacker
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CS309 ASSIGNMENT 4

Summary of Unit 4

Name – Jeevan S M

Roll No.- 22BCS049

Section - A
CATEGORICAL DATA ANALYSIS AND GOODNESS OF FIT TESTS

STATISTICS AND HEREDITY

Statistics and heredity are closely related in the study of genetics, where statistical methods are applied
to understand the transmission of traits from one generation to the next. This field, known as
quantitative genetics, uses statistical tools to analyze the inheritance of traits that are controlled by
multiple genes and influenced by environmental factors.

Statistics provides the tools to analyze the genetic data in heredity, allowing scientists to predict the
inheritance of traits, estimate genetic contributions to traits, and study the genetic architecture of
complex traits.

CHI-SQUARE TEST(χ²)

It is a inferential statistical test used to determine whether there is a significant association between
categorical variables. It is commonly applied in genetics, surveys, experiments, and other areas where
researchers analyze the relationship between observed frequencies and expected frequencies in data. It
requires no assumptions about the shape of the population distribution from which a sample is drawn.

The chi-square test is a versatile and widely used statistical tool, particularly in genetics and biology, to
test hypotheses regarding categorical data. It helps researchers determine whether observed outcomes
differ significantly from expected results based on theoretical models.

Types of Chi-Square

1. Chi-Square Test for Goodness of Fit:


This test determines whether the observed distribution of data fits a specific theoretical
distribution. It is useful when comparing observed data with expected outcomes based on a
hypothesis. For example, in Mendelian genetics, you might use it to test whether the observed
ratios of offspring phenotypes match the expected 3:1 ratio from a monohybrid cross.

Steps in Performing a Chi-Square Test for Goodness of Fit (with example):


1. State the Hypotheses:
● Null Hypothesis (H₀): The observed frequencies match the expected
frequencies (no significant difference).
● Alternative Hypothesis (H₁): The observed frequencies do not match the
expected frequencies (significant difference).

2. Set the Expected Frequencies:


● The expected frequencies are based on the theory, previous research, or a
hypothesized distribution (e.g., Mendelian ratios in genetics).
● For example, if you expect that a fair die should show each face with equal
probability, the expected frequency for each face would be
Total Rolls * (1/6)

For example, you roll a six-sided die 60 times and record the frequency of
each face. You want to test whether the die is fair, meaning each face has
an equal probability of occurring.

Observed Frequencies:
Face 1: 8 rolls
Face 2: 10 rolls
Face 3: 12 rolls
Face 4: 11 rolls
Face 5: 9 rolls
Face 6: 10 rolls

Expected Frequencies:
● Since the die is expected to be fair, each face should appear with
equal probability, i.e., 1/6 of the time.
● Expected frequency for each face: 1/6 * 60 = 10 rolls.

3. Calculate the Chi-Square Statistic:


● Use the formula:

χ2 = ∑ (O−E)^2/E

Where O = observed frequency, E = expected frequency

Face Observed(O) Expected(E) O–E (O - E)^2 (O-E)^2/E


1 8 10 -2 4 0.4
2 10 10 0 0 0.0
3 12 10 2 4 0.4
4 11 10 1 1 0.1
5 9 10 -1 1 0.1
6 10 10 0 0 0.0
Now, sum the (O - E)^2/E values to get the total chi-square statistic:
χ2 = 0.4+0.0+0.4+0.1+0.1+0.0=1.0

4. Determine Degrees of Freedom (df):


● The degrees of freedom for a goodness-of-fit test is:
df=Number of categories−1
● There are 6 categories (faces of the die), so the degrees of freedom:
df=6−1=5

5. Choose a Significance Level (α):


● Commonly chosen levels are 0.05 or 0.01.
● Let’s choose α=0.05 (for the example)

6. Compare the Chi-Square Statistic to the Critical Value:


● Using a chi-square distribution table, compare the calculated χ² value with
the critical value for the corresponding degrees of freedom at the chosen
significance level.
● If χ2 is greater than the critical value, reject the null hypothesis.
● Using a chi-square distribution table, for df=5 and α=0.05, the critical value
is 11.07

7. Interpret the Results:


● If the calculated p-value is less than α, or if χ2 is greater than the critical
value, conclude that the observed frequencies significantly differ from the
expected frequencies.
● The calculated chi-square statistic χ2=1.0 is less than the critical value of
11.07. Therefore, we fail to reject the null hypothesis (H₀).

2. Chi-Square Test for Independence:


This test checks whether two categorical variables are independent of each other. For instance,
it could be used to test whether there is an association between smoking and lung disease. It is
often applied using contingency tables to assess the relationship between different categorical
variables.

Steps in Performing a Chi-Square Test for Independence (with example):

1. State the Hypotheses:


● Null hypothesis (H₀): Assumes no association between the variables (they are
independent).
● Alternative hypothesis (H₁): Assumes there is an association between the variables
(they are dependent).

2. Set Up a Contingency Table:


● A contingency table shows the frequency of occurrences for different combinations
of categories.
Example:
Trait A Trait B (Present) Trait B (Absent) Row Total
Present 30 70 100
Absent 50 50 100
Column Total 80 120 200

3. Calculate Expected Frequencies:


● The expected frequency for each cell of the table is calculated based on the
assumption that the variables are independent. The formula for expected frequency
is:

E = (Row Total * Column Total)/(Grand Total)

For instance, the expected frequency for "Trait A Present and Trait B Present" would
be:

E = (100 * 80)/200 = 40

4. Compute the Chi-Square Statistic:


● The chi-square statistic (χ²) is calculated using the formula:

χ2 = ∑ (O−E)^2/E

Where O = observed frequency, E = expected frequency

For example, using the data from the contingency table:

χ2 = (30 - 40)^2/40 + (70 - 60)^2/60 +…..

5. Determine Degrees of Freedom (df):


● The degrees of freedom for a chi-square test in a contingency table is:

df=(number of rows−1)×(number of columns−1)

For a 2x2 table, this would be df = (2−1)(2−1) = 1.

6. Compare the Chi-Square Statistic with the Critical Value:


● Using a chi-square distribution table, compare the calculated χ² value with the
critical value at a specific significance level (usually 0.05) and the appropriate
degrees of freedom.
● If the calculated χ² is greater than the critical value, reject the null hypothesis
(indicating a significant association between variables).

7. Interpret the Results:


● If p < 0.05, you reject the null hypothesis, concluding that there is a statistically
significant association between the variables.
● If p ≥ 0.05, you fail to reject the null hypothesis, suggesting no significant
association.
3. Chi-Square Test for Homogeneity:
Similar to the test for independence, this test determines whether two or more populations
have the same distribution of a particular characteristic. It is used to compare the distributions
of different groups, such as comparing the frequency of a certain trait in different geographic
regions.

Steps in Performing a Chi-Square Test for Homogeneity (with example):

1. State the Hypotheses:


● Null Hypothesis (H₀): The distribution of the categorical variable is the same
across all populations.
● Alternative Hypothesis (H₁): The distribution of the categorical variable is
different for at least one population.

2. Collect Data and Construct a Contingency Table:


● A contingency table is created where each cell shows the observed frequency
for each combination of category and population.
● For example, suppose you want to test whether three different cities (City A,
City B, and City C) have the same distribution of individuals who are vaccinated
and unvaccinated against a certain disease.

You survey 200 people in each city, and the data is summarized in the table
below:
Vaccination City A City B City C Row Total
Status
Vaccinated 120 100 80 300
Unvaccinated 80 100 120 300
Column Total 200 200 200 600

3. Calculate the Expected Frequencies:


● For each cell, calculate the expected frequency using the formula:

E = (Row Total × Column Total)/ Grand Total

● For “Vaccinated in City A”:

E = (300 * 200)/600 = 100

● For “Vaccinated in City B”:

E = (300 * 200)/600 = 100

● For “Vaccinated in City C”:


E = (300 * 200)/600 = 100

The expected values:


Vaccination City A City B City C Row Total
Status
Vaccinated 100 100 100 300
Unvaccinated 100 100 100 300
Column Total 200 200 200 600

4. Compute the Chi-Square Statistic:


● Use the chi-square formula for each cell in the contingency table:

χ2 = ∑ (O−E)^2/E

Where O = observed frequency, E = expected frequency.


● For “Vaccinated in City A”:

(120 - 100)^2/100 = 20^2/100 = 400/100 = 4

● For “Unvaccinated in City A”:

(80 - 100)^2/100 = 20^2/100 = 400/100 = 4

● For “Vaccinated in City B”:

(100 - 100)^2/100 = 0

● For “Unvaccinated in City B”:

(100 - 100)^2/100 = 0

● For “Vaccinated in City C”:

(80 - 100)^2/100 = 20^2/100 = 400/100 = 4

● For “Unvaccinated in City C”:

(120 - 100)^2/100 = 20^2/100 = 400/100 = 4

Now sum all the (O−E)^2/E values to get the total chi-square statistic:

χ2 = 4 + 4 + 0 + 0 + 4 + 4 = 16

5. Determine Degrees of Freedom (df):


● The degrees of freedom for the chi-square test for homogeneity is:
df=(Number of Rows−1)×(Number of Columns−1)

● The degrees of freedom (df) for the chi-square test for homogeneity is:

df = (Number of Rows−1) × (Number of Columns−1) = (2−1)(3−1) = 2

6. Choose a Significance Level (α):


● Typically, α=0.05 is used.

7. Compare the Chi-Square Statistic to the Critical Value:


● Use a chi-square distribution table to find the critical value corresponding to the
degrees of freedom and chosen significance level.
● If χ2 is greater than the critical value, reject the null hypothesis.
● From the chi-square distribution table, the critical value for df = 2 and α = 0.05 is
5.991. Since χ2 = 16 is greater than the critical value of 5.991, we reject the null
hypothesis.

8. Interpret the Results:


● If the calculated ppp-value is less than α, or if χ2 is greater than the critical
value, you conclude that the distributions are not the same across populations.
● For the example, since the calculated chi-square statistic is greater than the
critical value, there is sufficient evidence to conclude that the distribution of
vaccinated and unvaccinated individuals is not the same across the three cities.

CHI-SQUARE TEST FOR 2X2 CONTINGENCY TABLE

It is used to determine if there is a significant association between two categorical variables, each with
two levels (binary categories). It's a special case of the Chi-Square Test for Independence and is widely
used in fields like medicine, genetics, and social sciences to compare proportions between two groups.

Steps in Performing a Chi-Square Test for a 2X2 Contingency Table (with example):

1. State the Hypotheses:


● Null Hypothesis (H₀): The two variables are independent (there is no association
between them).
● Alternative Hypothesis (H₁): The two variables are dependent (there is an association
between them).

2. Set Up a 2x2 Contingency Table:


● Organize the observed data in a table with two rows and two columns.
● The table has the following format:
Group 1 (Category Group 1 (Category Row total
1) 2)
Group 2 (Category O11 O12 R1
1)
Group 2 (Category O21 O22 R2
2)
Column Total C1 C2 N

Where Oij represents the observed frequencies in each cell, R1, R2 are the row totals, C1,
C2 are the column totals and N is the grand total (sum of all observations).

● For example, suppose you want to test whether there is an association between
smoking (yes/no) and lung disease (present/absent). You survey 100 people, and the
results are summarized in the following contingency table:
Lung Disease Lung Disease Row Total
(Present) (Absent)
Smoker 30 10 40
Non-smoker 10 50 60
Column Total 40 60 100

3. Calculate the Expected Frequencies:


● Use the formula to calculate the expected frequencies for each cell, assuming that the
variables are independent:

Eij = (Row Totali * Column Totalj)/Grand Total

● For E11 (Smoker and Lung Disease Present):

E11 = (40 * 40)/100 = 16

● For E12 (Smoker and Lung Disease Absent):

E12 = (40 * 60)/100 = 24

● For E21 (Non-smoker and Lung Disease Present):

E21 = (60 * 40)/100 = 24

● For E22 (Non-smoker and Lung Disease Absent):

E22 = (60 * 60)/100 = 36

● The expected frequency table is:


Lung Disease Lung Disease Row Total
(Present) (Absent)
Smoker 16 24 40
Non-smoker 24 36 60
Column Total 40 60 100
4. Compute the Chi-Square Statistic:
● Use the formula to calculate the chi-square statistic:
χ2 = ∑ (Oij−Eij)^2/Eij
where Oij = observed frequency, Eij = expected frequency.
● For O11 (Smoker and Lung Disease Present):

(30 - 16)^2/16 = 14^2/16 = 196/16 = 12.25

● For O12 (Smoker and Lung Disease Absent):

(10 - 24)^2/24 = 14^2/24 = 196/24 = 8.17

● For O21 (Non-smoker and Lung Disease Present):

(10 – 20)^2/24 = 14^2/24 = 196/24 = 8.17

● For O22 (Non-smoker and Lung Disease Absent):

(50 - 36)^2/36 = 14^2/36 = 196/36 = 5.44

● Now, sum these values to get the total chi-square statistic:

χ2 = 12.25 + 8.17 + 8.17 + 5.44 = 34.03

● Or the diect solution is, use the formula :

χ2 = N(ad - bc)^2/(a + b)(c + d)(a + c)(b + d) ~ χ2 (1)df

5. Determine the Degrees of Freedom (df):


● For a 2x2 table, the degrees of freedom is:

df = (2−1)(2−1) = 1

6. Choose a Significance Level (α):


● Common significance levels are 0.05 or 0.01.
● Let α = 0.05.

7. Compare the Chi-Square Statistic to the Critical Value:


● Use a chi-square distribution table to find the critical value for 1 degree of freedom and
the chosen significance level.
● If χ2 is greater than the critical value, reject the null hypothesis.
● From the chi-square distribution table, the critical value for df=1 at α=0.05 is 3.841.
Since χ2=34.03 is much greater than the critical value of 3.841, we reject the null
hypothesis.
8. Interpret the Results:
● If the calculated p-value is less than α, or if χ2 is greater than the critical value, conclude
that there is a significant association between the two variables.

YATES CORRECTION FOR CONTINUITY

It is a modification applied to the chi-square test for 2x2 contingency tables when the sample sizes are
small. It reduces the bias introduced by the fact that the chi-square test may overestimate statistical
significance when dealing with small data sets. Yates' correction is designed to make the chi-square test
more conservative by adjusting the difference between observed and expected values before squaring
it. It also called Yates' chi-square test.

● Yates' correction is recommended when the degrees of freedom are 1, i.e., when you're
dealing with a 2x2 contingency table.
● It is especially useful when one or more expected frequencies are small (typically less
than 5).

Formula for Yates Correction:

The Yates-corrected chi-square formula for each cell in a 2x2 contingency table is:

χ2 = N{|(ad - bc)| - (N/2)}^2/(a + b)(c + d)(a + c)(b + d) ~ χ2 (1)df

The rest of the procedure (degrees of freedom, significance level, etc.) remains the same as the
standard chi-square test.

Steps to Perform Yates' Correction:

1. Set up a 2x2 contingency table with observed frequencies.


2. Calculate the expected frequencies for each cell, as you would in a normal chi-square test.
3. Apply Yates' correction by subtracting 0.5 from the absolute difference between the observed
and expected frequencies before squaring the result.
4. Calculate the chi-square statistic using the corrected differences.
5. Determine the degrees of freedom (for a 2x2 table, df=1).
6. Compare the calculated chi-square value with the critical value from the chi-square distribution
table (or use a p-value).

You might also like