This graphic illustrates how subjective income perception is associated with depression scores. It tests Hypothesis 1: people who perceive their income as insufficient tend to report higher levels of depressive symptoms.
library(likert)
df$d20 = as.numeric(df$fltdpr)
df$d21 = as.numeric(df$flteeff)
df$d22 = as.numeric(df$slprl)
df$d23 = as.numeric(df$wrhpp)
df$d24 = as.numeric(df$fltlnl)
df$d25 = as.numeric(df$enjlf)
df$d26 = as.numeric(df$fltsd)
df$d27 = as.numeric(df$cldgng)
df$d23 = 5 - df$d23
df$d25 = 5 - df$d25
df_austria <- df[df$cntry == "Austria", ]
df_austria <- df_austria[, order(names(df_austria))]
library(likert)
library(kableExtra)
vnames = c("fltdpr","flteeff","slprl","wrhpp","fltlnl","enjlf","fltsd","cldgng")
likert_df = df[,vnames]
likert_table = likert(likert_df)$results
likert_numeric_df = as.data.frame(lapply((df[,vnames]), as.numeric))
likert_table$Mean = unlist(lapply((likert_numeric_df[,vnames]), mean, na.rm=T)) # ... and append new columns to the data frame
likert_table$Count = unlist(lapply((likert_numeric_df[,vnames]), function (x) sum(!is.na(x))))
likert_table$Item = c(
d20="How much of the time during the past week did you felt depressed?",
d21="How much of the time during the past week did you felt that everything you did was an effort?",
d22="How much of the time during the past week did your sleep was restless?",
d23="How much of the time during the past week did you were happy?",
d24="How much of the time during the past week did you felt lonely?",
d25="How much of the time during the past week did you enjoyed life?",
d26="How much of the time during the past week did you felt sad?",
d27="How much of the time during the past week did you could not get going?")
likert_table[,2:6] = round(likert_table[,2:6],1)
# round means to 3 decimal digits
likert_table[,7] = round(likert_table[,7],3)
# Create depression scale as average of 8 CES-D items.This scale is used as a metric outcome in the first regression model.
df$depression_scale <- rowMeans(cbind(df$d20, df$d21, df$d22, df$d23, df$d24, df$d25, df$d26, df$d27), na.rm = TRUE)
A boxplot is used to display the distribution of
average depression scores across four income perception groups:
- Comfortable
- Coping
- Difficult
- Very Difficult
Each box summarizes the median, quartiles, and outliers for that group.
df$income_perception <- factor(df$hincfel,
levels = c("Living comfortably on present income",
"Coping on present income",
"Difficult on present income",
"Very difficult on present income"),
labels = c("Comfortable", "Coping", "Difficult", "Very Difficult"))
library(ggplot2)
plot_data <- df[!is.na(df$income_perception) & !is.na(df$depression_scale), ]
p <- ggplot(plot_data, aes(x = income_perception, y = depression_scale)) +
geom_boxplot(fill = "tomato") +
labs(title = "Depression Scores by Income Perception",
x = "Income Perception",
y = "Average Depression Score")
print(p)
This boxplot shows that average depression scores increase as subjective income perception worsens. The trend supports Hypothesis 1 that individuals with more financial strain report higher levels of depressive symptoms.