Subsetting to country

 switzerland_data <- ess %>%
  filter(cntry == "CH")
df <- switzerland_data

Creating/cleaning main outcome variable.

## 
##    1  102    2    3    4   96  999 
##  739    2 7122 6550 2468    4   40
## 
##    1    2    3    4    5   99 
##  333 1457 3809  136 2031    2
## Warning: The histogram argument is only supported for (a) output types "default",
##   "html", "kableExtra", or "gt"; (b) writing to file paths with extensions
##   ".html", ".jpg", or ".png"; and (c) Rmarkdown, knitr or Quarto documents
##   compiled to PDF (via kableExtra)  or HTML (via kableExtra or gt). Use
##   `histogram=FALSE` to silence this warning.

Unique (#)

Missing (%)

Mean

SD

Min

Median

Max

age_num

7

0

5.0

48.4

1.0

3.0

999.0

educ_ba_num

2

0

0.2

0.4

0.0

0.0

1.0

health_num

7

0

1.9

0.8

1.0

2.0

8.0

## Warning: The histogram argument is only supported for (a) output types "default",
##   "html", "kableExtra", or "gt"; (b) writing to file paths with extensions
##   ".html", ".jpg", or ".png"; and (c) Rmarkdown, knitr or Quarto documents
##   compiled to PDF (via kableExtra)  or HTML (via kableExtra or gt). Use
##   `histogram=FALSE` to silence this warning.
Table 1. Descriptive statistics of main variables

Unique (#)

Missing (%)

Mean

SD

Min

Median

Max

age of respondent

7

0

5.0

48.4

1.0

3.0

999.0

highest level of education

2

0

0.2

0.4

0.0

0.0

1.0

Subjective general health

7

0

1.9

0.8

1.0

2.0

8.0

Hypothesis testing with infer

## Warning: Removed 9157 rows containing missing values.
## [1] 209.3982
## Warning: Removed 9157 rows containing missing values.
## Warning: Please be cautious in reporting a p-value of 0. This result is an
## approximation based on the number of `reps` chosen in the `generate()` step.
## See `?get_p_value()` for more information.
## # A tibble: 1 × 1
##   p_value
##     <dbl>
## 1       0
## Warning in min(diff(unique_loc)): no non-missing arguments to min; returning
## Inf

## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
Do some modelling
 (1)   (2)
age102 1.1 (1.2) 1.1 (1.2)
age2 1.5 (0.1)*** 1.5 (0.1)***
age3 1.4 (0.1)*** 1.5 (0.1)***
age4 0.9 (0.1)*** 1.0 (0.1)***
age96 2.1 (1.5) 2.2 (1.5)
age999 33.7 (0.9)*** 33.8 (0.9)***
health −0.2 (0.0)***
Num.Obs. 7768 7768
R2 0.181 0.186
R2 Adj. 0.180 0.185
AIC 30905.3 30858.9
BIC 30961.0 30921.5
Log.Lik. −15444.664 −15420.433
RMSE 1.79 1.78

Visual

## 
##  health effect
## health
##        1        3        4        6        8 
## 3.406097 3.045848 2.865724 2.505475 2.145226
Model 1  Model 2
(Intercept) 1.940 2.220
(0.075) (0.085)
age102 1.060 1.140
(1.198) (1.195)
age2 1.455 1.479
(0.080) (0.080)
age3 1.380 1.457
(0.081) (0.082)
age4 0.918 1.047
(0.094) (0.095)
age96 2.060 2.230
(1.535) (1.530)
age999 33.701 33.792
(0.890) (0.888)
health −0.180
(0.026)
Num.Obs. 7768 7768
R2 0.181 0.186
R2 Adj. 0.180 0.185
AIC 30905.3 30858.9
BIC 30961.0 30921.5
Log.Lik. −15444.664 −15420.433
RMSE 1.79 1.78