Work was done by:

Team “CandyCrash”

BSC-163

Gugnina Daria

Korolik Irina

Sokolova Anna

Country: Sweden

Topic: “Social inclusion and the level of happiness (desired and subjectively available) among men and women of different ages”

Preparation

Downolading packages

# libraries for tables
library(knitr)
library(kableExtra)

# for spss
library(foreign)

# for select
library(dplyr)

# library for graphs
library(ggplot2)

# for regression tables
library(stargazer)

library(GGally)
library(sjPlot)

Regression

Let’s start with the selection of variables relevant to our topic:

#set new directory
setwd("F:/gfgrf/ESS8SE_spss") 
getwd()
## [1] "F:/gfgrf/ESS8SE_spss"
ESS <- read.spss("ESS8SE.sav", use.value.labels=T, to.data.frame=T) 
 ESS1 <- select(ESS, c("sclmeet", "sclact", "nwspol", "agea", "gndr", "eduyrs", "region", "hinctnta", "wkhtot"))
ESS1 = na.omit(ESS1) 

plot(ESS1$hinctnta)

plot(ESS1$wkhtot)

Перекодируем наши переменные в тип numeric:

#перекодировка
ESS1$nwspol <-as.numeric(ESS1$nwspol) 
ESS1$sclmeet <-as.numeric(ESS1$sclmeet) 
ESS1$sclact <-as.numeric(ESS1$sclact)
ESS1$hinctnta <-as.numeric(ESS1$hinctnta) 
ESS1$wkhtot <-as.numeric(ESS1$wkhtot) 
ESS1$agea <-as.numeric(ESS1$agea) 
ESS1$eduyrs <-as.numeric(ESS1$eduyrs) 
ESS1$region <- as.numeric(ESS1$region)

#визуализация
hist(ESS1$nwspol)

hist(ESS1$eduyrs)

hist(ESS1$agea)

plot(ESS1$gndr)

hist(ESS1$hinctnta)

hist(ESS1$wkhtot)

hist(ESS1$sclmeet)

hist(ESS1$sclact)

plot(ESS1$region)

mean(ESS1$agea)
## [1] 38.0613
ESS1$agea_c <- ESS1$agea - mean(ESS1$agea) #center age

По гистограмме видно, что распределение зависимой переменной близко к нормальному.

H0: The distribution of nwspol does not differ from normal distribution.

H1: The distribution of nwspol differs from normal distribution.

shapiro.test(ESS1$nwspol)
## 
##  Shapiro-Wilk normality test
## 
## data:  ESS1$nwspol
## W = 0.95922, p-value < 0.00000000000000022

Также по тесту Шапира, p-value значимо (p-value < 0.00000000000000022), следовательно мы отвергаем нулевую гипотезу, значит распределение не нормальное.

ggpairs(ESS1[, 1:9])