Question: I have a python code for hypothesis testing for a statistics class and need help interpreting the results, an explantion of what the results mean,
I have a python code for hypothesis testing for a statistics class and need help interpreting the results, an explantion of what the results mean, and details about the null hypothesis, alternative hypothesis, and level of significance.
Results:
Hypothesis test for the difference of two population proportions - Step 2 (1.0561177090573837, 0.29091444062700333)
Hypothesis test for the difference of two population proportions - Step 3 (-2.1328430809234744, 0.032937600869161199)
Hypothesis test for the difference of two population means - Step 4 Ttest_indResult(statistic=1.2930625541846945, pvalue=0.20130524110032363)
Hypothesis test for the difference of two population means - Step 5 Ttest_indResult(statistic=-2.2438440532488544, pvalue=0.02990948832379026)
Code:
import pandas as pd import scipy.stats as st
##Step 1: Import your data set
manchesterweather = pd.read_csv('ManchesterWeather.csv')
###Step 2: Perform hypothesis test for the difference of two population proportions print ('Hypothesis test for the difference of two population proportions - Step 2') n1 = manchesterweather.loc[manchesterweather['Month'] == 7]['EMXT'].count() n2 = manchesterweather.loc[manchesterweather['Month'] == 8]['EMXT'].count() x1 = (manchesterweather.loc[manchesterweather['Month'] == 7]['EMXT'] > 325).values.sum() x2 = (manchesterweather.loc[manchesterweather['Month'] == 8]['EMXT'] > 325).values.sum() counts = [x1, x2] n = [n1, n2] print (proportions_ztest(counts, n)) print ('')
####### Step 3: Perform hypothesis test for the difference of two population proportions print ('Hypothesis test for the difference of two population proportions - Step 3') n1 = manchesterweather.loc[manchesterweather['Month'] == 2]['EMXP'].count() n2 = manchesterweather.loc[manchesterweather['Month'] == 8]['EMXP'].count() x1 = (manchesterweather.loc[manchesterweather['Month'] == 2]['EMXP'] > 200).values.sum() x2 = (manchesterweather.loc[manchesterweather['Month'] == 8]['EMXP'] > 200).values.sum() counts = [x1, x2] n = [n1, n2] print (proportions_ztest(counts, n)) print ('')
####### Step 4: Perform hypothesis test for the difference of two population means print ('Hypothesis test for the difference of two population means - Step 4') jul_data = manchesterweather.loc[manchesterweather['Month'] == 7]['EMXT'] aug_data = manchesterweather.loc[manchesterweather['Month'] == 8]['EMXT'] print (st.ttest_ind(jul_data, aug_data, equal_var=False)) print ('')
####### Step 5: Perform hypothesis test for the difference of two population means print ('Hypothesis test for the difference of two population means - Step 5') feb_data = manchesterweather.loc[manchesterweather['Month'] == 2]['EMXP'] aug_data = manchesterweather.loc[manchesterweather['Month'] == 8]['EMXP'] print (st.ttest_ind(feb_data, aug_data, equal_var=False)) print ('')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
