Author: Rok Stanič
The data used is the World Happiness Report of the year 2019 available at https://www.kaggle.com/datasets/unsdsn/world-happiness.
First I needed to get the data for each continent so I combined
the countries on the Aisian and the European continent, so I could see
if there is a difference and what kind of difference is there.
european_data <- subset(happiness, Continent == "Europe")
asian_data <- subset(happiness, Continent == "Asia")
summary(european_data$Score)
Min. 1st Qu. Median Mean 3rd Qu. Max.
5.011 6.052 6.659 6.556 7.207 7.769
summary(asian_data$Score)
Min. 1st Qu. Median Mean 3rd Qu. Max.
4.015 5.192 5.530 5.539 5.923 6.446
The mean of mesured happiness for Europe was 6.556 and for Asia
5.539.
I then preformed a Welch Two Sample t-test to compare the
means of the Happiness score(“Score”) variable between the two
continents. The results included the t-statistic, degrees of freedom,
p-value and a 95% confidence interval. I also preformed the Wilcoxon
rank sum test, a non-parametric test to compare the distribution of
scores between European and Asian countries. The results included the
test statistic(W), p-value and the alternative hypothesis.
t_test_result <- t.test(european_data$Score, asian_data$Score)
> wilcoxon_test_result <- wilcox.test(european_data$Score, asian_data$Score)
> print("T-Test Results:")
[1] "T-Test Results:"
> print(t_test_result)
Welch Two Sample t-test
data: european_data$Score and asian_data$Score
t = 4.3139, df = 24.911, p-value = 0.000222
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.5315119 1.5030214
sample estimates:
mean of x mean of y
6.556433 5.539167
> print("\nWilcoxon Test Results:")
[1] "\nWilcoxon Test Results:"
> print(wilcoxon_test_result)
Wilcoxon rank sum exact test
data: european_data$Score and asian_data$Score
W = 300, p-value = 0.00049
alternative hypothesis: true location shift is not equal to 0
Based on this report and the results, at least on the mean and
average happiness score people reported being happier on average in
european countries than in asian. Both the t-test and the wilcoxon test
suggest a significant difference between the scores of European and
asian coutnries, as the p-values are very small(less than 0.05). The
t.test assumes normality and is sensitive to outlires.