Introduction

This document analyzes depressive symptoms in Austria using data from the European Social Survey (ESS11). The analysis includes descriptive statistics and a regression model of the CES-D8 depression scale, using both unweighted and weighted approaches.

Loading Required Libraries

{r libraries} library(foreign) library(likert) library(kableExtra) library(psych)

Loading and Preparing the Data

{r data-loading} df <- read.spss(“ESS11.sav”, to.data.frame = TRUE, use.value.labels = TRUE)

Filter for Austria only

df_AT <- subset(df, cntry == “Austria”)

Depression Scale (CES-D8)

We construct the CES-D8 scale by using eight self-reported depression-related items. Two positively worded items are reverse-coded.

{r cesd8} # Convert items to numeric df_AT\(d1 <- as.numeric(df_AT\)fltdpr) df_AT\(d2 <- as.numeric(df_AT\)flteeff) df_AT\(d3 <- as.numeric(df_AT\)slprl) df_AT\(d4 <- as.numeric(df_AT\)wrhpp) df_AT\(d5 <- as.numeric(df_AT\)fltlnl) df_AT\(d6 <- as.numeric(df_AT\)enjlf) df_AT\(d7 <- as.numeric(df_AT\)fltsd) df_AT\(d8 <- as.numeric(df_AT\)cldgng)

Reverse score the positive items

df_AT\(d4 <- 5 - df_AT\)d4 df_AT\(d6 <- 5 - df_AT\)d6

Ensure numeric conversion is strict

scale_items <- df_AT[, c(“d1”, “d2”, “d3”, “d4”, “d5”, “d6”, “d7”, “d8”)] scale_items[] <- lapply(scale_items, function(x) as.numeric(as.character(x)))

Calculate reliability using the psych package

reliability_result <- alpha(scale_items) print(reliability_result$total)

Compute depression score (mean)

df_AT$CES_D8 <- rowMeans(scale_items, na.rm = TRUE)

Likert Table and Plot

Below we describe the eight items included in the CES-D8 depression scale:

  1. fltdpr – How much of the time during the past week did you feel depressed?
  2. flteeff – … did you feel that everything you did was an effort?
  3. slprl – … was your sleep restless?
  4. wrhpp – … did you feel happy? (positive, reverse-coded)
  5. fltlnl – … did you feel lonely?
  6. enjlf – … did you enjoy life? (positive, reverse-coded)
  7. fltsd – … did you feel sad?
  8. cldgng – … did you feel you could not get going?

These items were rated on a Likert scale and are used to assess the presence and intensity of depressive symptoms experienced in the past week.

We now present the individual items as a table and visualize the results using the likert package.

{r likert-table} likert_items <- df_AT[, c(“fltdpr”, “flteeff”, “slprl”, “wrhpp”, “fltlnl”, “enjlf”, “fltsd”, “cldgng”)]

Convert all to ordered factors

likert_items[] <- lapply(likert_items, function(x) factor(as.character(x), ordered = TRUE))

Create Likert object

likert_obj <- likert(likert_items)

Table of results

summary_likert <- likert_obj$results kable(summary_likert, caption = “Distribution of Depression Scale Responses”) %>% kable_styling()

{r likert-plot} # Plot plot(likert_obj)

Plot

plot(likert_obj)

Regression Analysis: CES-D8 Predictors

We now assess potential predictors of depressive symptoms using a linear regression model. The predictors include:

We test both unweighted and weighted models.

{r prepare-vars} # Convert relevant predictors to numeric if necessary df_AT\(fltlnl <- as.numeric(as.character(df_AT\)fltlnl)) df_AT\(sclmeet <- as.numeric(as.character(df_AT\)sclmeet)) df_AT\(health <- as.numeric(as.character(df_AT\)health)) df_AT\(dosprt <- as.numeric(as.character(df_AT\)dosprt))

Handle missing values by replacing with mode

replace_with_mode <- function(x) { mode_value <- names(sort(table(x), decreasing = TRUE))[1] x[is.na(x)] <- mode_value return(x) }

Apply to each predictor

Replace only if missing values exist and mode can be found

safe_replace_with_mode <- function(x) { x <- as.numeric(as.character(x)) if (any(is.na(x))) { non_na_values <- x[!is.na(x)] if (length(non_na_values) == 0) return(x) # nothing to replace mode_value <- as.numeric(names(sort(table(non_na_values), decreasing = TRUE))[1]) x[is.na(x)] <- mode_value } return(x) }

df_AT\(fltlnl <- safe_replace_with_mode(df_AT\)fltlnl) df_AT\(sclmeet <- safe_replace_with_mode(df_AT\)sclmeet) df_AT\(health <- safe_replace_with_mode(df_AT\)health) df_AT\(dosprt <- safe_replace_with_mode(df_AT\)dosprt)

Check again for factor issues

df_AT\(sclmeet <- as.numeric(as.character(df_AT\)sclmeet)) df_AT\(health <- as.numeric(as.character(df_AT\)health)) df_AT\(dosprt <- as.numeric(as.character(df_AT\)dosprt))

Unweighted Model

{r unweighted-model} # Subset complete cases for model variables model_data <- df_AT[, c(“CES_D8”, “fltlnl”, “sclmeet”, “health”, “dosprt”)] model_data <- na.omit(model_data)

Fit model

model_unweighted <- lm(CES_D8 ~ fltlnl + sclmeet + health + dosprt, data = model_data) summary(model_unweighted)

Weighted Model (using dweight)

{r weighted-model} # Subset complete cases including dweight model_data_w <- df_AT[complete.cases(df_AT[, c(“CES_D8”, “fltlnl”, “sclmeet”, “health”, “dosprt”, “dweight”)]), ]

Fit weighted model

model_weighted <- lm(CES_D8 ~ fltlnl + sclmeet + health + dosprt, data = model_data_w, weights = dweight) summary(model_weighted)

Model Comparison

{r model-comparison} cat(“R-squared unweighted:”, round(summary(model_unweighted)\(r.squared, 3), "\n") cat("R-squared weighted: ", round(summary(model_weighted)\)r.squared, 3), “”)

The weighted model shows a slightly different R-squared, indicating the influence of survey weights on model performance. Compare coefficients for further interpretation.