Author: Rok Stanič

1. research question: Is there a diffrence in happiness beetween european and asain countries?

1.1 Data

The data used is the World Happiness Report of the year 2019 available at https://www.kaggle.com/datasets/unsdsn/world-happiness.

1.2 Analysis


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


1.3 Conclusion


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.


2. research question: Are economic factors, social support, and life expectancy signifficant in the happiness scores of countries?


2.1 Data


The data used is a different one but aso a world happiness report but from 2021, avaliable at https://www.kaggle.com/datasets/ajaypalsinghlo/world-happiness-report-2021.

2.2 Analysis


First we examine the descriptive statistics of the variables used.

summary(data$Ladder.score)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.523   4.852   5.534   5.533   6.255   7.842
summary(data$Logged.GDP.per.capita)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   6.635   8.541   9.569   9.432  10.421  11.647
summary(data$Social.support)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.4630  0.7500  0.8320  0.8147  0.9050  0.9830
summary(data$Healthy.life.expectancy)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   48.48   59.80   66.60   64.99   69.60   76.95


Before proceeding with regression analysis, I had to check the assumptions: Linearity: Check scatterplots to assess the rough linearity between the dependent and independent variables. Independence: Verify the independence of residuals through residual plots. Homoscedasticity: Ensure constant variance of residuals across all levels of independent variables. Normality of Residuals: Check if residuals follow a normal distribution.


Detirmining there is no great need to tweak the data I preform the reggression analysis with the chosen explanatory variables

model <- lm(Ladder.score ~ Logged.GDP.per.capita + Social.support + Healthy.life.expectancy, data = data)
summary(model)
## 
## Call:
## lm(formula = Ladder.score ~ Logged.GDP.per.capita + Social.support + 
##     Healthy.life.expectancy, data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.81242 -0.40736  0.01624  0.47390  1.31845 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             -2.40583    0.47808  -5.032 1.41e-06 ***
## Logged.GDP.per.capita    0.27335    0.09419   2.902  0.00429 ** 
## Social.support           3.00051    0.70315   4.267 3.56e-05 ***
## Healthy.life.expectancy  0.04486    0.01447   3.101  0.00232 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6013 on 145 degrees of freedom
## Multiple R-squared:  0.6928, Adjusted R-squared:  0.6865 
## F-statistic:   109 on 3 and 145 DF,  p-value: < 2.2e-16


2.3 Conclusion


The regression analysis indicates significant associations between the Happiness score(“Ladder score”) and its predictors. All coefficients, including the intercept, “Logged.GDP.per.capita,” “Social.support,” and “Healthy.life.expectancy,” are statistically significant (p-values < 0.05).

The positive coefficient for “Logged.GDP.per.capita” (0.27335) implies that higher logged GDP per capita corresponds to an increased predicted Ladder score. Similarly, positive coefficients for “Social.support” (3.00051) and “Healthy.life.expectancy” (0.04486) suggest that higher social support and healthy life expectancy are linked to higher predicted Happiness scores.

The model explains a substantial proportion of the Ladder score variance (Multiple R-squared = 0.6928), indicating a good fit. The overall F-statistic is highly significant, affirming the model’s collective significance.

In summary, the regression model underscores the importance of GDP per capita, social support, and healthy life expectancy as predictors of the happiness score. The model is statistically significant.