Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chi-squared Test - Hands-on Step1of4 Installations Let's get the installations done, prior to creating tasks. Run the command given below. pip install --user numpy scipy

Chi-squared Test - Hands-on

Step1of4

Installations

Let's get the installations done, prior to creating tasks.

Run the command given below.

pip install --user numpy scipy

prettytable

Editor Usage

Instructions

1.Open app.py file using vim editorvim app.py

2.Pressifor inserting content into file.

3.Write the required python code.

4.Save the file by pressingEsckey and typing:wqin editor.

5.Execute the script with commandpython app.py | tee output.txt

6.Click on Continue to move to next Task.

Do the Hypothesis Testing

The table shows the contingency table of marital status by education. Use Chi-Square test for testing Homogenity.contingency table of marital status by education.

View the table by executing the following command

python

from prettytable import PrettyTable

t = PrettyTable(['Marital Status','Middle school', 'High School','Bachelor','Masters','PhD'])

t.add_row(['Single',18,36,21,9,6])

t.add_row(['Married',12,36,45,36,21])

t.add_row(['Divorced',6,9,9,3,3])

t.add_row(['Widowed',3,9,9,6,3])

print (t)

exit()

Hypothesis

Null Hypothesis: There is no difference in distribution between the types of education level in terms of marital status.

Alternate Hypothesis: There is a Difference

Code it

Coding

1.Importchi2_contingencyandchi2fromscipy.statspackage.

2.Declare a 2D array with the values mentioned in the contingency table of marital status by education.

3.Calculate and print the values of

- Chi-Square Statistic - Degree of Freedom - P value - Hint: Use chi2_contingency() function 

4.Assume the alpha value to be 0.05

5.Compare the P value with alpha and decide whether or not to reject the null hypothesis.

- If Rejected print "Reject the Null Hypothesis" - Else print "Failed to reject the Null Hypothesis" 

Execute the script with commandpython app.py | tee output.txt

Sample output 2.33 4.5 8.9

Reject the Null Hypothesis

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Combinatorial Dynamics And Entropy In Dimension One

Authors: Lluis Alseda, Jaume Llibre, Michal Misiurewicz

1st Edition

9810213441, 9789810213442

More Books

Students also viewed these Mathematics questions

Question

LO11.6 Review bad-news messages for effectiveness and fairness.

Answered: 1 week ago