Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Practical 5 – CP2403

(Please ensure you show your work to your tutor once completed as each practical is 3
marks.)

Ensure you add you name to the top of the jupyter notebook.
Part 1 – Download the Jupyter notebook for Week 5 and run the notebook

Part 2
Ensure you have completed Prac 1, Prac 2 and Prac 3.
Download the Jupyter Notebook Template for Prac 5 from LearnJCU. Complete the template
& run the code. Refer to Module 5 Lecture Jupyter Notebook for help
Complete the questions in Part 3 as you work on the Prac 5 template

Part 3
Scenario 1
We want to find out if the mean number of beers consumed per-month (NUMBEERMO_EST)
is equal for individuals with and without dysthymia (DYSLIFE)

Step 1: hypothesis
Null hypothesis (Ho):
There is no difference in the mean number of beers consumed per-month between with
and without dysthymia (DYSLIFE).

Alternative (Ha) hypothesis:


There is difference in the mean number of beers consumed per-month between with and
without dysthymia (DYSLIFE).

Step 2: Data Selection

We select data from nesarc dataset


- adults 26-50 years old
- consumed beers per-month

Step 3: Assess the evidence (ANOVA)


F-statistics: 20.23
Prob(F-statistics): 6.99e-06

Mean values:
0 27.227714(without dysthymia,27 beers consumed per month)
1 40.194719(with dysthymia,40 beers consumed per month)

STD values:
0 47.678467
1 75.407118

Step 4: Draw Conclusion

Since p-value is greater than 0.05 (p = 6.99e-06 =13.0007 > 0.05),


Accept (There is no difference in the mean number of beers consumed per month
between with and without dysthymia (DYSLIFE).

Box Plot of beers consumed per-month (NUMBEERMO_EST) for individuals with and
without dysthymia (DYSLIFE)

Scenario 2
We want to find out if the mean number of beers consumed per-month (NUMBEERMO_EST)
is equal for adults from different ethnic group

Step 1: hypothesis
Null hypothesis (Ho):
There is no difference in the mean number of beers consumed per-month between adults
from different ethnic group.

Alternative (Ha) hypothesis:


There is a difference in the mean number of beers consumed per-month between adults
from different ethnic group.

Step 2: Data Selection

We select data from nesarc dataset


- adults 26-50 years old
- consumed beers per-month

Step 3: Assess the evidence (ANOVA)


F-statistics: 8.261

Prob(F-statistics): 1.21e-06

Mean values:
White 27.858922
Black 32.443182
NatAm 39.508475
Asian 16.600000
Hispanic 24.618638

STD values:
White 50.537013
Black 55.289755
NatAm 57.231386
Asian 25.572698
Hispanic 41.073842

Step 4: Draw Conclusion


Since p-value is smaller than 0.05 (p = 1.21e-06 = -2.7 < 0.05),
Reject (There is no difference in the mean number of beers consumed per month
between adults from difference ethnic group).
Post-hoc analysis results

==================================================
group1 group2 meandiff lower upper reject
--------------------------------------------------
Asian Black 15.8432 5.4332 26.2532 True
Asian Hispanic 8.0186 -2.1752 18.2124 False
Asian NatAm 22.9085 7.2827 38.5343 True
Asian White 11.2589 1.4533 21.0646 True
Black Hispanic -7.8245 -13.1332 -2.5159 True
Black NatAm 7.0653 -5.9129 20.0435 False
Black White -4.5843 -9.103 -0.0655 True
Hispanic NatAm 14.8898 2.0844 27.6953 True
Hispanic White 3.2403 -0.7553 7.2359 False
NatAm White -11.6496 -24.1482 0.8491 False

True for difference between Asian (group1) and Black, NatAm and White from group 2,
and for difference between Black (group1) and Hispanic, NatAm from group 2, and for
difference between Hispanic from group 1 and group 2 from NatAm.

Post-hoc analysis conclusion

We can say that most of the people from Asian ethnicity consumed beer significantly
more than Black, NatAm and White. Also, people from Black ethnicity consumed beer
more than Hispanic and NatAm ethnicity. Overall, Asian ethnicity consumed beer the
most.

Box Plot of beers consumed per-month (NUMBEERMO_EST) for individuals from


different ethnicity background

You might also like