Analisis Regresi Linear Berganda terhadap Faktor-Faktor yang Mempengaruhi Tingkat Kebahagiaan Negara

Pendahuluan

Penelitian ini bertujuan untuk menganalisis faktor-faktor yang mempengaruhi tingkat kebahagiaan suatu negara berdasarkan data World Happiness Report. Variabel yang digunakan dalam penelitian ini meliputi GDP per capita, social support, dan healthy life expectancy yang diduga berpengaruh terhadap skor kebahagiaan suatu negara.

Analisis Data

# IMPORT LIBRARY
library(readr)
library(lmtest)
library(car)

# IMPORT DATA
data_happiness <- read_csv("world-happiness-report.csv")

# MELIHAT DATA
head(data_happiness)
## # A tibble: 6 × 9
##   `Overall rank` `Country or region` Score `GDP per capita` `Social support`
##            <dbl> <chr>               <dbl>            <dbl>            <dbl>
## 1              1 Finland              7.77             1.34             1.59
## 2              2 Denmark              7.6              1.38             1.57
## 3              3 Norway               7.55             1.49             1.58
## 4              4 Iceland              7.49             1.38             1.62
## 5              5 Netherlands          7.49             1.40             1.52
## 6              6 Switzerland          7.48             1.45             1.53
## # ℹ 4 more variables: `Healthy life expectancy` <dbl>,
## #   `Freedom to make life choices` <dbl>, Generosity <dbl>,
## #   `Perceptions of corruption` <dbl>
summary(data_happiness)
##   Overall rank    Country or region      Score       GDP per capita  
##  Min.   :  1.00   Length:156         Min.   :2.853   Min.   :0.0000  
##  1st Qu.: 39.75   Class :character   1st Qu.:4.545   1st Qu.:0.6028  
##  Median : 78.50   Mode  :character   Median :5.380   Median :0.9600  
##  Mean   : 78.50                      Mean   :5.407   Mean   :0.9051  
##  3rd Qu.:117.25                      3rd Qu.:6.184   3rd Qu.:1.2325  
##  Max.   :156.00                      Max.   :7.769   Max.   :1.6840  
##  Social support  Healthy life expectancy Freedom to make life choices
##  Min.   :0.000   Min.   :0.0000          Min.   :0.0000              
##  1st Qu.:1.056   1st Qu.:0.5477          1st Qu.:0.3080              
##  Median :1.272   Median :0.7890          Median :0.4170              
##  Mean   :1.209   Mean   :0.7252          Mean   :0.3926              
##  3rd Qu.:1.452   3rd Qu.:0.8818          3rd Qu.:0.5072              
##  Max.   :1.624   Max.   :1.1410          Max.   :0.6310              
##    Generosity     Perceptions of corruption
##  Min.   :0.0000   Min.   :0.0000           
##  1st Qu.:0.1087   1st Qu.:0.0470           
##  Median :0.1775   Median :0.0855           
##  Mean   :0.1848   Mean   :0.1106           
##  3rd Qu.:0.2482   3rd Qu.:0.1412           
##  Max.   :0.5660   Max.   :0.4530
# MODEL REGRESI
model1 <- lm(Score ~ `GDP per capita` + `Social support` + `Healthy life expectancy`,
             data = data_happiness)

summary(model1)
## 
## Call:
## lm(formula = Score ~ `GDP per capita` + `Social support` + `Healthy life expectancy`, 
##     data = data_happiness)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7018 -0.4155 -0.0520  0.4535  1.3369 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.1350     0.2116  10.088  < 2e-16 ***
## `GDP per capita`            0.8098     0.2358   3.434 0.000766 ***
## `Social support`            1.3219     0.2483   5.324 3.58e-07 ***
## `Healthy life expectancy`   1.2977     0.3661   3.544 0.000523 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.588 on 152 degrees of freedom
## Multiple R-squared:  0.7263, Adjusted R-squared:  0.7209 
## F-statistic: 134.5 on 3 and 152 DF,  p-value: < 2.2e-16
# UJI NORMALITAS
error <- model1$residuals
ks.test(error,"pnorm",mean(error),sqrt(var(error)))
## 
##  Asymptotic one-sample Kolmogorov-Smirnov test
## 
## data:  error
## D = 0.055543, p-value = 0.7216
## alternative hypothesis: two-sided
# UJI AUTOKORELASI
dwtest(model1)
## 
##  Durbin-Watson test
## 
## data:  model1
## DW = 1.5577, p-value = 0.00223
## alternative hypothesis: true autocorrelation is greater than 0
# UJI MULTIKOLINEARITAS
vif(model1)
##          `GDP per capita`          `Social support` `Healthy life expectancy` 
##                  3.956068                  2.473462                  3.522742
# UJI HETEROSKEDASTISITAS
bptest(model1)
## 
##  studentized Breusch-Pagan test
## 
## data:  model1
## BP = 2.0697, df = 3, p-value = 0.5581
# SCATTERPLOT

plot(data_happiness$`GDP per capita`,
     data_happiness$Score,
     main="Scatterplot GDP per capita vs Happiness Score",
     xlab="GDP per capita",
     ylab="Happiness Score",
     pch=19,
     col="steelblue")

abline(lm(Score ~ `GDP per capita`,
          data = data_happiness), col="red")

plot(data_happiness$`Social support`,
     data_happiness$Score,
     main="Scatterplot Social Support vs Happiness Score",
     xlab="Social Support",
     ylab="Happiness Score",
     pch=19,
     col="darkgreen")

abline(lm(Score ~ `Social support`,
          data = data_happiness), col="red")

plot(data_happiness$`Healthy life expectancy`,
     data_happiness$Score,
     main="Scatterplot Healthy Life Expectancy vs Happiness Score",
     xlab="Healthy Life Expectancy",
     ylab="Happiness Score",
     pch=19,
     col="purple")

abline(lm(Score ~ `Healthy life expectancy`,
          data = data_happiness), col="red")