Skip to content

Analyzing Students Mental Health, Using PostgreSQL

Field NameDescription
inter_domTypes of students (international or domestic)
japanese_cateJapanese language proficiency
english_cateEnglish language proficiency
academicCurrent academic level (undergraduate or graduate)
ageCurrent age of student
stayCurrent length of stay in years
todepTotal score of depression (PHQ-9 test)
toscTotal score of social connectedness (SCS test)
toasTotal score of acculturative stress (ASISS test)
Spinner
DataFrameas
df
variable
SELECT *
FROM students;

Analysing Lenght of Stay Impacts on Mental Health Diagnostic:

Objective: To explore and analyze the students data to see how the length of stay (stay) impacts the average mental health diagnostic scores of the international students present in the study.

  • Do international students have higher/lower depression scores than domestic students?
  • How does the academic level influence it? Which group (grad/under) is more prone to depression?
  • What is the correlation between the total score of depression (todep) and length of stay for international students?

Are international students with a longer stay more prone to depression?

  1. I selected the stay column and calculated the average scores for todep (PHQ-9 test), tosc (SCS test), and toas (ASISS test), which represent the study’s mental health diagnostic measures. I rounded these values to two decimal places. To make the analysis easier to understand, I mapped the original data columns to my results as follows:

Total score of depression (todep) → average_phq Total score of social connectedness (tosc) → average_scs Total score of acculturative stress (toas) → average_as

  1. Since my focus is on international students, I counted the number of international students (count_int) for each length of stay.

  2. Finally, I sorted the results by length of stay in descending order.

Spinner
DataFrameas
df
variable
SELECT stay,
       COUNT(inter_dom) AS count_int, 
       ROUND(AVG(todep), 2) AS average_phq, 
       ROUND(AVG(tosc), 2) AS average_scs, 
       ROUND(AVG(toas), 2) AS average_as
FROM students
WHERE inter_dom = 'Inter'
GROUP BY stay
ORDER BY 1 DESC;

Compare Depression Scores by Academic Level

The previous result made me want to understand more of the data to determine if the academic level could be an influential factor

Spinner
DataFrameas
df1
variable
SELECT stay, 
       academic, 
       COUNT(*) AS count_students, 
       ROUND(AVG(todep), 2) AS average_phq, 
       ROUND(AVG(tosc), 2) AS average_scs, 
       ROUND(AVG(toas), 2) AS average_as
FROM students
WHERE tosc IS NOT NULL 
AND toas IS NOT NULL 
AND todep IS NOT NULL
GROUP BY academic, stay
ORDER BY stay, count_students DESC;

We can see that the majority of students are undergraduates

Compare Average Depression Scores Between Groups

The following query calculates the average depression, social connectedness, and acculturative stress for each group.It gives a high-level comparison between the two populations (international vs domestic students)

Spinner
DataFrameas
df
variable
SELECT inter_dom, 
       COUNT(*) AS count_students, 
       ROUND(AVG(todep), 2) AS average_phq, 
       ROUND(AVG(tosc), 2) AS average_scs, 
       ROUND(AVG(toas), 2) AS average_as
FROM students
WHERE todep IS NOT NULL 
AND tosc IS NOT NULL 
AND toas IS NOT NULL
GROUP BY inter_dom;

Compare Depression Scores by Stay Duration for Both Groups

  • Do international students' depression scores increase with longer stays?
Spinner
DataFrameas
df4
variable
SELECT stay, 
       inter_dom, 
       COUNT(*) AS count_students, 
       ROUND(AVG(todep), 2) AS average_phq, 
       ROUND(AVG(tosc), 2) AS average_scs, 
       ROUND(AVG(toas), 2) AS average_as
FROM students
WHERE todep IS NOT NULL 
AND tosc IS NOT NULL 
AND toas IS NOT NULL
GROUP BY stay, inter_dom
ORDER BY stay DESC, inter_dom;

What is the correlation between the the total score of depression (todep) and lenght of stay?

I used the PostgreSQL CORR () function to calculate how stay relates to depression and grouped the results by academic level.