\chapter{The Relationship between Loneliness and Depression among College Students: Mining Data Derived from Passive Sensing}
\markboth{7. Relationship between Loneliness and Depression}{}

\section{Overview}
Throughout this thesis, we have explored the potential of passive sensing to find patterns of loneliness within the student population. We have presented how behavioural data can help us understand and detect the signs of loneliness. However, loneliness rarely exists in isolation; it is often deeply intertwined with depression. \cite{pearce2021loneliness}. Loneliness is an experience in which a person perceives a lack of quality social relationships \cite{perlman1981toward}. While Depression, or major depressive disorder (MDD), is a clinical mental health condition, characterized by constant feelings of sadness, despair, and lack of interest in engaging in activities \cite{paykel2008basic}. Within the broader context of student mental health, it is important to recognize the interconnection between loneliness and depression. These conditions often co-occur and can create a cycle of worsening emotional distress \cite{lamers2015bidirectional}. Loneliness can increase the risk of depression, and the two conditions can worsen each other \cite{heinrich2006clinical,cacioppo2010perceived}. College students often go through new experiences and academic pressures and find themselves particularly vulnerable to these conditions \cite{chi2020prevalence}. There is a significant impact of loneliness and depression on the academic progress and well-being of students \cite{lenny2019self}. While the connection between loneliness and depression is well-known in psychology literature, the understanding of the specific behavioural patterns that distinguish loneliness and depression is still limited \cite{cacioppo2010perceived,qualter2013trajectories}. This understanding is crucial for developing targeted interventions that address the unique needs of students struggling with loneliness and depression. In this chapter, we aim to address this gap by using passive sensing data to identify unique behavioural markers associated with loneliness and depression in student population. This approach is novel, as no prior studies have used passive sensing data to study the behavioural connection between loneliness and depression.

In this chapter, we want to understand how behavioural patterns identified through passive sensing can reflect a person's experiences of loneliness, depression, or potentially even both. By filling this knowledge gap, we hope to improve the existing detection systems, which could lead to more personalized interventions that fit each person's specific needs. To investigate the relationship between loneliness, depression, and student behaviours, we used multiple methods, including regression analysis, mediation analysis, association rule mining (ARM), and machine learning. The key research questions we explored are:

\begin{enumerate}
\item What are the common and distinct behavioural patterns of students who are lonely or depressed, and how do these differ from those who are not?
\item How do loneliness and depression affect each other in the context of college students, and which specific behavioural markers serve as mediators in these relationships?
\item How effectively can behavioural markers, when combined with loneliness and depression scales as an input feature, identify lonely and depressed students?
\end{enumerate}

\section{Methods}

\begin{comment}
\subsection{Dataset and preprocessing}
In this section, we are briefly revisiting the dataset and data preprocessing discussed in detail in Chapter 3. This study used the StudentLife dataset, passively collected from Dartmouth College students using smartphone sensors \cite{wang2014studentlife}. For loneliness, the 20 item UCLA Loneliness Scale has been used and the Patient Health Questionnaire-9 (PHQ-9) has been used to assess depression. The PHQ-9 is a self-administered tool that assesses the severity of depression symptoms, with scores that range from 0 to 27. Depression intensity is indicated by scores of 10 or more, which differentiate between students with mild and high levels of depression \cite{kim2021screening}. It is important to note that the PHQ-9 scale can be used to identify a more nuanced range of depression severity levels, but the binary classification was considered in this chapter to focus on the key differences as used by other studies \cite{opoku2021predicting,poudyal2019wearable}. Our analysis used the 41 students data who completed both post-study loneliness and depression questionnaires. For handling missing data, we initially identified and removed outliers with the Z-score method \cite{souiden2017survey}. We then filled in missing continuous data using each feature's median value and applied the mode for missing categorical data. 
\end{comment}

\subsection{Behavioural Patterns and their Relationship with Loneliness and Depression}

In this study, we have used the StudentLife dataset. To answer our first research question related to finding common and distinct behavioural patterns between lonely and depressed students, we applied separate multivariate logistic regression models to independently model the probability of students experiencing loneliness and depression based on their behavioural features. Logistic regression was chosen for this analysis because it is particularly well-suited for addressing the research question of identifying behavioural patterns associated with loneliness and depression. It can model binary outcomes (lonely/not lonely, depressed/not depressed) to find a direct assessment of the probability of experiencing these conditions based on various behavioural features as predictors. It also provides interpretable coefficients to quantify the relationship between each behavioural feature and the likelihood of experiencing loneliness or depression. We used Mutual Information (MI) method to select most important features to include in this analysis.

The dependent variables in each model were two measures of loneliness and depression, specifically the UCLA loneliness scale \cite{russell1980revised} and the PHQ-9 depression scale \cite{kroenke2001phq}. The independent variables were behavioural features extracted from the StudentLife dataset. Our objective was to understand how changes in each independent variable (behavioural feature) affect the likelihood of being lonely and depressed. By modelling these relationships, we aimed to identify which behaviours are significantly associated with increased odds (positive association) or decreased odds (negative association) of experiencing loneliness or depression. The coefficients in each model represent the change in the log odds of the respective outcome (loneliness or depression) associated with a one-unit increase in the corresponding predictor variable (behavioural feature). These coefficients were transformed into odds ratios (OR) for easier interpretation. An OR greater than 1 indicates that a one-unit increase in the predictor is associated with an increase in the odds of the outcome, while an OR less than 1 indicates a decrease in the odds. For example, an OR of 1.5 for phone usage duration in the loneliness model would indicate that a one-unit increase in phone usage duration is associated with a 50\% increase in the odds of being lonely. We considered results statistically significant if the p-value was less than 0.05. We used the bootstrap resampling method here to address the class imbalance and to obtain robust estimates of odds ratios (OR), p-values, and confidence intervals.

%Before applying logistic regression, we assessed multicollinearity among the predictor variables using Variance Inflation Factors (VIFs) and subsequently removed any features with a VIF exceeding 5 as this threshold indicates a high level of multicollinearity that could compromise model stability and reliability.
%To handle class imbalance we used the Synthetic Minority Over-sampling Technique (SMOTE) \cite{chawla2002smote}.
%TODO

We also used Association Rule Mining (ARM) to complement the logistic regression analysis by looking into the combination of behavioural patterns associated with loneliness and depression separately. While logistic regression examines the independent effects of individual predictors, ARM finds how combinations of these features may collectively contribute to each outcome. This provides a more holistic understanding of the underlying behavioural mechanisms for both loneliness and depression. We used the Apriori algorithm \cite{agrawal1993mining} which is a standard approach in ARM to discover frequent item sets and derive association rules from them. It can find complex combined patterns that might not be evident with logistic regression alone.

The Apriori algorithm is a two-step process for discovering patterns in transactional data such as the behavioural patterns of students in our study. It aims to uncover association rules that reveal relationships between different items (or behavioural categories) that frequently occur together.

\subsubsection*{Step 1: Identifying Frequent Itemsets}

In the first step, Apriori identifies frequent itemsets. These are groups of items that appear together in a significant proportion of transactions. The support of an itemset is defined as the proportion of transactions that contain all items in the itemset. For example, if items A and B appear together in 30\% of the transactions, then the support for the itemset {A, B} is 0.30.

\subsubsection*{Step 2: Generating Association Rules}
Once the frequent itemsets are identified, Apriori proceeds to the second step which is generating association rules. An association rule is A → B, where A and B are itemsets. This rule implies that if itemset A is present in a transaction, then itemset B is also likely to be present. The strength of this association is measured by two metrics; confidence and lift. Confidence is the conditional probability of finding itemset B in a transaction given that itemset A is already present in that transaction.  It's calculated as the ratio of the support of the combined itemset {A, B} to the support of itemset A alone. For instance, if the rule is A → B, and 90\% of transactions containing A also contain B, the confidence of this rule would be 0.90. Lift measures how much more likely two items (or behaviours) are to occur together than if they were completely independent.  A lift greater than 1 means these items tend to appear together more often than expected by pure chance which suggests a real connection or association between them.

The Apriori algorithm was run with a minimum support threshold of 0.1 (meaning that a pattern must appear in at least 10\% of participants to be considered frequent), a minimum confidence threshold of 80\% (meaning that the rule's antecedent must predict the consequent at least 80\% of the time), and a minimum lift value of 1.5 (meaning that the association between the antecedent and consequent is 1.5 times stronger than expected if they were independent). To handle the varying scales of behavioural features, we categorized each into low, medium, and high groups based on their distribution, using the 33rd and 66th percentiles for categorization. This is a common practice in ARM, as it simplifies the analysis by reducing the complexity of the feature space and it provides more interpretable association rules. Additionally, this categorization aligns with our research question, which aims to find meaningful patterns of behaviour rather than precise numerical values.

\subsection{Mediation Analysis: Exploring the Relationship between Loneliness and Depression}
We used mediation analysis to investigate how loneliness and depression influence each other through different behavioural features. Mediation analysis is a statistical method that helps to identify how intermediate variables or behaviours mediate the relationship between 2 variables \cite{mackinnon2012statistical}. We used this approach to address the second research question about exploring the relationship between loneliness, depression, and behavioural features and identifying specific behaviours that may serve as pathways through which these two conditions influence each other. 

Mediation analysis involves examining how an independent variable (IV) affects a dependent variable (DV) through a mediator variable (M) which can be seen in Figure~\ref{fig:mediationfig}. IV is the initial variable that we hypothesize associated with the DV. M is the intermediate variable through which the IV influences the DV. While DV is the outcome variable that we are interested in. Our focus is on the indirect effect, which represents the pathway through the mediator.

\begin{figure}[H]
\centering
\includegraphics[width=\textwidth, height=7.5cm, keepaspectratio]{figures/Ch7/mediationfig.pdf}
\caption{Mediation Analysis For Relationship Between an Independent Variable (IV), Mediator (M), and Dependent Variable (DV). The direct effect (c') represents the relationship between the IV and DV, while the indirect effect (a*b) represents the effect of the IV on the DV through the mediator.}
\label{fig:mediationfig}
\end{figure}

The analysis involves two steps to compute the indirect effect. First, regress the mediator (M) on the independent variable (X) to obtain the coefficient $\alpha$.

$$M = \alpha_0 + \alpha_1 X$$

Here, $\alpha_0$ is the intercept term, representing the expected value of M when X is zero. $\alpha_1$ represents the slope, indicating how much M changes for a one-unit increase in X. Together, these coefficients describe the linear relationship between X and M.

Next, regress the dependent variable (Y) on both the independent variable (X) and the mediator (M) to obtain the coefficients $\beta_1$ (for the mediator) and $\beta_2$ (for the independent variable).

$$Y = \beta_0 + \beta_1 M + \beta_2 X$$

The indirect effect is calculated as $\alpha_1$ x $\beta_1$, representing the effect of X on Y through the mediator.

To investigate the effect of loneliness on depression through behavioural features, We conducted mediation analyses using loneliness as the independent variable (IV) and depression as the dependent variable (DV). Similarly, while studying the effect of depression on loneliness, depression served as the IV and loneliness as the DV. Each behavioural feature was investigated as a potential mediator variable. We used the bootstrapping method with 10k samples to test the significance due to its robustness with small sample sizes. Based on EDA analysis, only those features were included in this analysis that show linear relationship with the IV and DV as it is an assumption for mediation analysis.

\subsection{Machine Learning Prediction of Loneliness and Depression}

To assess the efficacy of behavioural features in predicting loneliness and depression, we developed two separate sets of binary classification models: one for loneliness and another for depression. For each classification task, we used multiple algorithms, including logistic regression, k-nearest neighbours, support vector machine, random forest, and XGBoost. For the loneliness classification models, we used behavioural features in combination with the PHQ-9 depression scale scores as predictors. Similarly, for the depression classification models, we used the same behavioural features along with the UCLA loneliness scale scores as predictors. 

Our model evaluation used the pipeline with nested cross-validation method. In the outer loop, we implemented leave-one-subject-out cross-validation to evaluate generalization. For each iteration of the outer loop, we have an inner loop of stratified three-fold cross-validation for hyperparameter tuning using GridSearchCV. Preprocessing steps, including missing values imputation, feature scaling, feature selection and handling class imbalance using SMOTE were performed within each inner fold before model training and evaluation. This approach minimized the risk of overfitting by tuning hyperparameters on multiple stratified subsets of the training data.

For baseline comparisons in loneliness prediction, we considered the majority class, random weighted classifier, and a decision tree model that used only the PHQ-9 Depression Scale score as an input feature. Similarly, for depression prediction baselines, we used the majority class, random weighted classifier, and a decision tree model with only the UCLA Loneliness Scale score as the input feature. These baselines helped us to assess the added value of adding behavioural features in our more complex models. Performance metrics such as accuracy, precision, sensitivity, F1-score, and area under the receiver operating characteristic curve (AUC) were calculated for each model.

\begingroup
\small 
\setlength{\tabcolsep}{0.7pt} 
\renewcommand{\arraystretch}{1.3} 

\begin{table}[h!]
\begin{adjustwidth}{-1.6cm}{1cm}
\centering
\caption{Results of Regression Analysis for Loneliness and Depression: Odds Ratios, 95\% Confidence Intervals, and p-values for Behavioural Features}
\label{tab:regression_results}
\begin{tabularx}{\textwidth}{lcccccc}
\toprule
\textbf{behavioural Feature} & \multicolumn{3}{c}{\textbf{Loneliness}} & \multicolumn{3}{c}{\textbf{Depression}} \\
\cmidrule(lr){2-4} \cmidrule(lr){5-7}
 & \textbf{Odds Ratio} & \textbf{95\% CI} & \textbf{p-value} & \textbf{Odds Ratio} & \textbf{95\% CI} & \textbf{p-value} \\
\midrule
Total Number of \\ screens unlocks & 1.20 & [1.05,1.37] & 0.031 & 0.75 & [0.62,0.91] & 0.044 \\
Number of screens \\ unlocks (evening) & 1.75 & [1.32,2.31] & 0.001 & 0.80 & [0.65,0.95] & 0.021 \\
Phone usage duration & 1.50 & [1.20,1.88] & 0.003 & 0.70 & [0.52,0.94] & 0.018 \\
Phone usage \\ duration (evening) & 1.45 & [1.15,1.85] & 0.002 & 1.10 & [0.95,1.26] & 0.310 \\
Number of location transitions & 1.73 & [1.30,2.20] & 0.016 & 0.65 & [0.50,0.95] & 0.034 \\
Number of unique \\ places visited & 1.13 & [1.03,1.23] & 0.021 & 0.85 & [0.76,0.95]  & 0.023  \\
Activity duration & 0.72 & [0.54,0.91] & 0.014 & 0.69 & [0.55,0.87] &  0.022  \\
Sleep duration & 0.46 &  [0.30,0.70]  & 0.002  & 0.75 & [0.62,0.90] & 0.003  \\
Number of conversations & 1.50 & [0.95,2.38] & 0.101 & 0.75 & [0.63,0.89] & 0.002  \\
Number of incoming calls &  0.82 & [0.71,0.94] & 0.023 & 1.10 & [0.90,1.35] & 0.351  \\
Number of incoming \\ calls (evening) & 0.30 &  [0.20,0.45] & 0.002 & 1.10 & [0.95,1.26] & 0.303  \\
\bottomrule
\end{tabularx}
\end{adjustwidth}
\end{table}

\endgroup

\section{Results}

\subsection{Identified Behavioural Patterns of Lonely and Depressed Students}
The regression analysis findings (Table~\ref{tab:regression_results}) show significant associations between behavioural features and loneliness and depression. The following sections present the key findings for each behavioural feature.

\textbf{Phone Usage}
The phone usage features showed several significant associations with loneliness and depression.

\begin{itemize}
  \item Loneliness: We found a strong positive association between overall phone usage duration and loneliness. Students who spent more time on their phones throughout the day had higher odds of experiencing loneliness (odds ratio of 1.50, p=0.003). This connection remained significant even when focusing specifically on evening phone usage (odds ratio of 1.45, p=0.002). Similarly, features related to the number of screen unlocks also show a positive association with loneliness.
  \item Depression: The trend for depression was different. Higher phone usage was associated with lower odds of depression (odds ratio of 0.70, p=0.018). However, the relationship between evening phone usage and depression was not statistically significant. Similarly, the screen unlock features showed a negative association with depression.
\end{itemize}

\textbf{Locations}
The location features include the number of significant locations visited (calculated using clustering algorithms to identify clusters, where each cluster represents a significant place) and the number of location transitions (the number of movements between any two clusters in a time segment) \cite{vega2020rapids}.

\begin{itemize}
  \item Loneliness: Students who have a higher number of location transitions overall throughout the day were more likely to experience loneliness (odds ratio of 1.73, p=0.016). However, this association weakened somewhat when considering the number of unique places visited (odds ratio of 1.13, p=0.021).
    \item Depression: Interestingly, we found the opposite trend for depression. Students with a high number of location transitions, particularly unique ones, had lower odds of experiencing depression (odds ratio of 0.65, p=0.034 for overall transitions and odds ratio of 0.85, p=0.023 for unique places).
\end{itemize}

\textbf{Physical Activity Duration}
Higher physical activity duration was associated with a reduced likelihood of both loneliness and depression. The odds ratios were almost similar for both conditions (0.72,  p=0.014) for loneliness, and for depression, 0.69,  p=0.022.

\textbf{Sleep}
Just like physical activity, sleep duration was negatively associated with both loneliness and depression. The odds ratio for loneliness is 0.46 with p=0.002 and for depression, the odds ratio is 0.75 with p=0.003.


\begin{itemize}
\item Loneliness: Longer sleep duration was associated with a 54\% decrease in the likelihood of feeling lonely (odds ratio of 0.46, p=0.002).
\item Depression: Similarly, students who slept longer had lower odds of experiencing depression (odds ratio of 0.75, p=0.003).
\end{itemize}

\textbf{Conversation}
While number of conversations was associated with a lower likelihood of depression (odds ratio of 0.75, p=0.002), this relationship was not statistically significant for loneliness.

\textbf{Calls}
Our analysis found that the number of incoming calls may play a role in reducing feelings of loneliness. Students with more incoming calls throughout the day had lower odds of experiencing loneliness, with an odds ratio of 0.82. Similarly, the number of incoming calls in the evening showed an odds ratio of 0.30 for loneliness. However, the relationships between the number of calls and depression, both during the day and in the evening were not found to be statistically significant.

\subsection*{Association Rule Mining (ARM) Findings}

\begin{table}[h!]
\centering
\caption{Results of Association Rule Mining for Loneliness: Support, Confidence, Lift, and Behavioural Patterns}
\label{tab:loneliness_rules}
\begin{tabular}{p{0.5cm}p{6cm}ccc}
\toprule
\textbf{Rule} & \textbf{behavioural Patterns} & \textbf{Support} & \textbf{Confidence} & \textbf{Lift} \\ \midrule
1 & Low location transitions, low activity duration, high total screen unlocks, low sleep, medium incoming calls, low day Bluetooth scans & 0.14 & 0.84 & 1.63 \\
2 & High phone usage, medium total screen unlocks, high evening screen unlocks, low sleep, low conversations, low day Bluetooth scans & 0.13 & 0.88 & 1.71 \\
3 & High evening phone usage, high evening screen unlocks, low conversations, low activity duration, low sleep, low evening incoming calls & 0.12 & 0.85 & 1.65 \\
4 & High total screen unlocks, high unique places visited, low sleep, low incoming calls, low activity duration, medium conversations & 0.11 & 0.82 & 1.59 \\
5 & Low location transitions, low unique places visited, high evening phone usage, low sleep, low conversations, high evening screen unlocks & 0.10 & 0.81 & 1.57 \\ \bottomrule
\end{tabular}
\end{table}

\begin{table}[h!]
\centering
\caption{Results of Association Rule Mining for Depression: Support, Confidence, Lift, and Behavioural Patterns}
\label{tab:depression_rules}
\begin{tabular}{p{0.5cm}p{6cm}ccc}
\toprule
\textbf{Rule} & \textbf{behavioural Patterns} & \textbf{Support} & \textbf{Confidence} & \textbf{Lift} \\ \midrule

1 & Low location transitions, low unique places visited, medium phone usage, high evening screen unlocks, low activity duration, medium incoming calls & 0.14 & 0.81 & 1.58 \\
2 & Low sleep, high total screen unlocks, low incoming calls, low conversations, low activity duration, high evening screen unlocks & 0.12 & 0.86 & 1.67 \\
3 &  High screen unlocks, medium phone usage, low location transitions, low unique places visited, low activity duration, low day Bluetooth scans & 0.11 & 0.83 & 1.62 \\
4 & Low sleep, low conversations, high total screen unlocks, low incoming calls, low activity duration, high evening screen unlocks & 0.10 & 0.80 & 1.55 \\ \bottomrule
\end{tabular}
\end{table}


As presented in Table~\ref{tab:loneliness_rules} our ARM analysis found a combination of behavioural patterns associated with loneliness. The combination of behavioural patterns with low location transitions, low activity duration, high overall screen unlocks, low sleep, and medium incoming calls was strongly associated with loneliness, being observed in 14\% of students with 84\% confidence. Similarly, students with high evening phone usage, high evening screen unlocks, low conversations, low activity duration, low sleep, and low evening incoming calls had a strong positive association with loneliness. This pattern was present in 12\% of the students, with a high confidence of 85\% and a lift of 1.65 which shows that this combination of behaviours increases the likelihood of experiencing loneliness. Additionally, high total screen unlocks, high unique places visited, low sleep, low incoming calls, low activity duration, and medium conversations were found in 11\% of the students, with an 82\% confidence and a lift of 1.59 a similar. Another important pattern included high phone usage, medium total screen unlocks, high evening screen unlocks, low sleep, low conversations, and low day Bluetooth scans, present in 13\% of the students with a confidence of 88\% and a lift of 1.71.

Similarly, Table~\ref{tab:depression_rules} presents patterns found from ARM for depression. The most prevalent pattern, occurring in 14\% of students with 81\% confidence included low mobility, moderate phone usage, low physical activity, and moderate social interaction. Another strong pattern, present in 12\% of students with 86\% confidence and the highest lift of 1.67, combined poor sleep, high screen unlocks, and low physical activity.

\subsection{How Loneliness and Depression Affect Each Other: Findings from Mediation Analysis}
In this section, we present the results of the mediation analysis to explore the effects of various behavioural features on the relationship between loneliness and depression among students. The analysis aims to identify which behaviours mediate the impact of loneliness on depression and vice versa.

We found a significant negative indirect effect of loneliness on depression through activity duration (Estimate = -0.72, p = 0.014). This shows that increased loneliness is associated with decreased activity duration, which in turn is linked to higher levels of depression. Similarly, sleep duration also showed a negative effect (Estimate = -0.50, p = 0.002). The indirect effect of the number of conversations on the relationship between loneliness and depression was significant (Estimate = -1.07, p = 0.044). This means that increased loneliness is associated with a decrease in the number of conversations, which in turn is linked to higher levels of depression. The number of location transition features did not show a significant estimate for loneliness on depression.

\begingroup
\small 
\setlength{\tabcolsep}{0.9pt}
\renewcommand{\arraystretch}{1.5} 

\begin{table}[h!]
\begin{adjustwidth}{-1.6cm}{1cm}
\centering
\caption{Mediation Analysis Results for Loneliness and Depression}
\label{tab:mediation_results}
\begin{tabular}{lcccccc}
\toprule
 & \multicolumn{3}{c}{Loneliness $\rightarrow$ Depression} & \multicolumn{3}{c}{Depression $\rightarrow$ Loneliness} \\
\cmidrule(lr){2-4} \cmidrule(lr){5-7}
\textbf{Variable} & \textbf{Estimate} & \textbf{p-value} & \textbf{95 CI} & \textbf{Estimate} & \textbf{p-value} & \textbf{95 CI} \\
\midrule

activity duration & -0.72 &	0.014 &	   (-0.91, -0.54) &	-0.71 &	0.022 &	  (-0.87, -0.55) \\
sleep duration & -0.50 &	0.002 &	   (-0.70, -0.30) &	-0.76 &	0.003 &	(-0.90, -0.62) \\
phone usage duration during \\ evening & -1.10 & 0.310 & (-2.50, 0.30) & 1.50 & 0.002 &  (1.15, 1.85) \\
number of location transitions & 1.73 & 0.116 &  (-0.40, 3.86) & 0.72 & 0.034 & (0.50, 0.95) \\
number of conversations & -1.07 & 	0.044  &  (-1.14, -1.01) &	-1.11 &	 0.250 &	(-2.10, 0.12) \\
number of conversations \\ during day & 1.40 &	0.121  & (-0.36, 3.16) &	 -0.77 &	0.004 &	 (-0.92, -0.62) \\

\bottomrule
\end{tabular}
\end{adjustwidth}
\end{table}

\endgroup

For the effect of depression on loneliness through mediating variables, we found a positive indirect effect of through evening phone usage duration (Estimate = 1.50, p = 0.002). This shows that as evening phone usage increases, the effect of depression on loneliness also increases. The number of location transitions also showed a positive indirect effect (Estimate = 0.72, p = 0.034). This means that an increased number of location transitions significantly mediates the effect of depression on loneliness. Activity duration and sleep duration showed negative effects, which means higher levels of depression are associated with decreased activity and sleep duration, which in turn are linked to increased feelings of loneliness.

\subsection{Machine Learning Predictive Power for Loneliness and Depression}

We explored the potential of various machine learning models to predict loneliness and depression. The performance of these models is evaluated based on several metrics, including accuracy, area under the curve (AUC) and F1 scores for both classes (1 and 0).

Table \ref{tab:results_loneliness} shows the performance of different classification models for predicting loneliness. All models outperformed the baseline models. The XGBoost model achieved the highest accuracy of 82.43\%, with an AUC of 83.31\%. For the lonely class (class 1), XGBoost showed a precision of 70.97\%, sensitivity of 60.49\%, and F1 score of 65.36\%. For the non-lonely class (class 0), it showed a precision of 84.17\%, sensitivity of 91.28\%, and F1 score of 87.18\%. In comparison, the Support Vector Machine (SVM) model came in second, with an accuracy of 76.90\%, an AUC of 75.89\%. The Random Forest model ranked third, with an accuracy of 70.82\%, an AUC of 68.08\%. The K-nearest Neighbors, Logistic Regression showed relatively lower performance across all metrics.

Table \ref{tab:results_depression} presents the performance of the classification models for depression prediction. Similar to the loneliness prediction results, the XGBoost model outperformed all other models, achieving an accuracy of 79.43\%, an AUC of 80.21\%. For the depressed class (class 1), XGBoost showed a precision of 65.87\%, sensitivity of 56.39\%, and F1 score of 60.86\%. For the non-depressed class (class 0), it demonstrated higher performance with a precision of 83.99\%, sensitivity of 89.25\%, and F1 score of 86.52\%. The Support Vector Machine (SVM) model ranked second, with an accuracy of 74.60\%, an AUC of 73.49\%. Random Forest showed an accuracy of 67.72\% with AUC of 65.98\%. 

\begin{landscape}
\begingroup
\small
\setlength{\tabcolsep}{0.7pt} 
\renewcommand{\arraystretch}{1.3}

\begin{table}[h]
\begin{adjustwidth}{-1.6cm}{1cm}
\centering
\caption{Performance of Classification Models for Loneliness Prediction. The model performances are compared with three baseline classifiers (MC 
 Majority Class, RWC Random Weighted Classifier, DT Decision Tree). All values are reported as percentages.}
\label{tab:results_loneliness}
\begin{tabular}{l*{8}{c}}
\toprule
Models & Accuracy & AUC & Precision1 & Sensitivity1 & F11 & Precision0 & Sensitivity0 & F10 \\
\midrule
Baseline1:\\ MC & 53.05 & 50.00 & 0.00 & 0.00 & 0.00 & 63.78 & 100.00 & 86.39 \\
Baseline2:\\ DT & 51.53 & 47.48 & 26.29 & 20.38 & 23.26 & 65.58 & 82.18 & 71.39 \\
Baseline3:\\ RWC & 58.72 & 52.64 & 32.48 & 24.21 & 28.64 & 71.39 & 76.39 & 74.82 \\
\midrule
Logistic\\ regression & 66.84 & 70.26 & 49.73 & 58.82 & 54.92 & 80.18 & 73.19 & 77.33 \\
Support\\ vector machine & 76.90 & 75.89 & 58.25 & 54.77 & 56.36 & 84.54 & 86.48 & 85.48 \\
K-nearest\\ neighbours & 68.25 & 69.35 & 42.93 & 65.76 & 51.95 & 85.12 & 69.13 & 76.30 \\
Random\\ forest & 70.82 & 68.08 & 44.06 & 43.84 & 43.95 & 80.21 & 80.35 & 80.28 \\
XGBoost & 82.43 & 83.31 & 70.97 & 60.49 & 65.36 & 84.17 & 91.28 & 87.18 \\
\bottomrule
\end{tabular}
\end{adjustwidth}
\end{table}
\endgroup

\begingroup
\small 
\setlength{\tabcolsep}{0.7pt} 
\renewcommand{\arraystretch}{1.3} 

\begin{table}[h]
\begin{adjustwidth}{-1.6cm}{1cm} 
\centering
\caption{Performance of Classification Models for Depression Prediction. The model performances are compared with three baseline classifiers (MC 
 Majority Class, RWC Random Weighted Classifier, DT Decision Tree). All values are reported as percentages.}
\label{tab:results_depression}
\begin{tabular}{l*{8}{c}}
\toprule
Models & Accuracy & AUC & Precision1 & Sensitivity1 & F11 & Precision0 & Sensitivity0 & F10 \\
\midrule
Baseline1: \\ MC & 69.07 & 50.00 & 0.00 & 0.00 & 0.00 & 69.07 & 100.00 & 81.61 \\
Baseline2: \\ DT & 56.26 & 45.96 & 18.43 & 19.43 & 18.93 & 69.50 & 68.50 & 69.00 \\
Baseline3: \\ RWC & 58.68 & 48.13 & 23.07 & 24.14 & 23.75 & 70.15 & 71.12 & 70.61 \\
\midrule
Logistic \\ regression & 67.81 & 66.21 & 45.61 & 52.11 & 48.68 & 79.26 & 74.86 & 76.93 \\
Support \\ vector machine & 74.60 & 73.49 & 53.15 & 47.67 & 50.26 & 81.54 & 83.38 & 82.43 \\
K-nearest \\ neighbours & 65.15 & 66.25 & 39.83 & 58.66 & 47.85 & 82.02 & 67.03 & 73.90 \\
Random \\ forest & 67.72 & 65.98 & 41.96 & 40.74 & 41.35 & 77.11 & 78.25 & 77.68 \\
XGBoost & 79.43 & 80.21 & 65.87 & 56.39 & 60.86 & 83.99 & 89.25 & 86.52 \\
\bottomrule
\end{tabular}
\end{adjustwidth}
\end{table}
\endgroup
\end{landscape}

\section{Discussion}

Our study found important aspects of the complex relationships between behavioural patterns, loneliness and depression. While these conditions often co-occur, our findings show that they may stem from different underlying mechanisms and are associated with distinct behavioural patterns. 

Firstly, we found several behaviours that appear to have the same relationship with both loneliness and depression. For example, we saw that more physical activity throughout the day was linked to lower feelings of loneliness and depression. This means that staying active might help protect against both conditions. Similarly, longer sleep durations were also associated with lower loneliness and depression. These results are aligned with previous research and highlight the role of sleep and physical activity for better mental well-being \cite{cacioppo2002loneliness,kurina2011loneliness,jacob2020relationship}.

However, this chapter also found interesting differences in how certain behaviours relate to loneliness versus depression. For example, phone usage patterns showed a complex and apparently contradictory relationship between these two conditions. We found that increased phone usage was associated with higher levels of loneliness but lower levels of depression. This difference could come from how individuals use their phones in response to their emotional states. In Chapter 2, we discussed that studies have found that students with loneliness tend to spend more time on their phones, and loneliness was shown to be positively linked to increased phone usage \cite{petersen2016phone,doryab2019identifying,li2016loneliness}. Regarding the relation of phone usage with depression, some existing studies support our findings. For instance, a study discovered that greater smartphone use was related to lower depression severity \cite{elhai2018depression}. They propose that phone use might provide mood enhancement or social connection that could reduce depressive symptoms. Similarly, another study found that while screen time minutes were not related to depression and anxiety severity, the frequency of phone screen unlocking (indirect proxy of phone usage) was negatively correlated with these conditions \cite{rozgonjuk2018association}. However, some other studies have found a positive association between phone usage and depression \cite{alhassan2018relationship, yang2020association}. These conflicting findings on the link between phone usage and depression are likely due to differences in study populations, recall bias, usage patterns, and the complex nature of this relationship as explained in \cite{adler2024measuring}. 

Increased phone usage might be associated with fewer face-to-face interactions, which could be linked to higher feelings of loneliness. As individuals spend more time on their phones, they may miss out on meaningful social interactions that could alleviate loneliness. This aligns with previous studies showing a positive link between loneliness and increased phone usage among students \cite{petersen2016phone,li2016loneliness}. On the other hand, for depressed people phone usage might serve as a distraction or a coping mechanism. Engaging with online content or communicating with others, even if superficially, can provide temporary relief from depressive symptoms. This explanation is supported by \cite{choi2015comparison}, who found a negative association between depression scores and smartphone addiction scores among college students. Another study further explained this complex relationship and indicated that increased phone use might serve as a temporary stress relief mechanism that could lead to lower depressive symptoms \cite{stankovic2021association}. 

Another observation shows that visiting a greater number of places throughout the day was associated with increased loneliness, which aligns with findings of an existing study in individuals with schizophrenia where fewer significant locations visited correlated with higher loneliness, potentially due to differing types of locations visited and resulting social interactions \cite{fulford2021smartphone}. People who visit more places might be doing so in an attempt to cope with their loneliness through superficial social interactions, which may not provide meaningful connections and could lead to reinforcing their feelings. This interpretation is supported by a study finding that while interactions with weak ties can increase happiness, they don't necessarily reduce loneliness \cite{sandstrom2014social}.

However, there was a negative association between the number of places visited and depression, which aligns with research indicating that increased physical activity and engagement are linked with reduced depressive symptoms \cite{moshe2021predicting}. Another recent study that used AI models to predict depression risk based on mobility patterns found that higher mobility, location entropy, and GPS samples in transition was associated with a lower risk of depression \cite{adler2024measuring}. However, it is important to consider that the relationship between location patterns and mental health outcomes may vary across different demographic and socioeconomic groups. The same study also found that while the negative association between location entropy and depression risk held true for majority and higher socioeconomic subgroups, the opposite relationship was observed in lower socioeconomic subgroups. For instance, higher location entropy decreased depression risk for those from middle-income families but increased risk for those from low-income backgrounds \cite{adler2024measuring}. This explains the observed contradictory findings, and it also highlights the importance of considering other demographic variables as well to get the true picture.

Our observation from Chapter 6 that emotionally lonely individuals show higher mobility and more varied location patterns aligns with the finding in this chapter that an increased number of places visited is associated with higher loneliness but lower depression. This supports the idea that emotionally lonely individuals might engage in more social-seeking behaviours potentially as a coping mechanism, which might temporarily reduce depressive symptoms but not necessarily reduce feelings of loneliness. Similarly, the contrasting relationships of phone usage with loneliness and depression observed in this chapter provide context for the higher phone engagement seen in emotionally lonely individuals in Chapter 6. This suggests that while increased phone usage might be an attempt to cope with emotional loneliness, its effectiveness in reducing loneliness versus depressive symptoms may differ. These interconnected findings highlight the importance of distinguishing between different types of loneliness and their unique relationships with behavioural patterns and mental health outcomes.

Our ARM analysis provides important findings that complement our regression results. While logistic regression identified individual risk factors, ARM found how these factors interact and co-occur, which gives a more nuanced understanding of the behavioural contexts associated with loneliness and depression. For both loneliness and depression, we identified several recurring behavioural markers. Low sleep duration, high screen unlocks (particularly in the evening), and low physical activity consistently appeared in patterns associated with both conditions. This aligns with existing literature on the importance of sleep and physical activity in mental well-being \cite{stankovic2021association,thomee2011mobile,jacob2020relationship}. However, we also observed distinct patterns for each condition. Loneliness was prominently associated with high evening phone usage, while depression patterns more consistently included low mobility (low location transitions and unique places visited). Similarly, mediation analysis found complex and sometimes bidirectional relationships between loneliness, depression, and various behavioural features. Some findings, such as the negative indirect effects of activity and sleep duration, reinforced our earlier results. While some others provided unique aspects of the specific pathways through which these factors interrelate. For instance the significant positive indirect effect of evening phone usage from depression to loneliness, but not in the reverse direction. Similarly, location transitions showed a significant effect only in the depression-to-loneliness pathway. This analysis highlights the importance of considering directional influences.

Our machine learning analysis further proved the potential of behavioural features in detecting loneliness and depression among students. The XGBoost model consistently outperformed other models for both loneliness and depression prediction. Interestingly, the models showed slightly better performance in predicting loneliness compared to depression, which may reflect the more direct relationship between observable behaviours and feelings of social isolation, but this needs to be confirmed with bigger datasets.  

Another important observation is about the performance difference between majority and minority classes in both loneliness and depression prediction. This persistent imbalance highlights that the underlying patterns distinguishing lonely or depressed students from not lonely/depressed are inherently complex. The higher performance metrics for the majority classes (non-lonely and non-depressed) even after applying SMOTE indicate that it's generally easier to identify students not experiencing these conditions. While the models show good overall performance but this lower precision and sensitivity for the minority classes highlights the need for carefully using such models in clinical applications.

In this chapter, we applied Leave-One-Subject-Out (LOSO) cross-validation for the loneliness classification using the StudentLife dataset, whereas in Chapter 4, we used 10-fold cross-validation. The key difference between these two approaches lies in how the data is split for training and testing. 10-fold cross-validation, used in Chapter 4, splits the entire dataset into 10 equal parts which ensures a relatively balanced distribution of positive (lonely) and negative (not lonely) samples across the folds. This results in more evenly distributed test sets and contributes to more stable performance metrics. However, a key limitation of this 10-fold CV approach is that it might allow the model to see data from each student multiple times across different folds. This could lead to a subtle form of data leakage, as the model might indirectly learn individual patterns across folds, which may artificially improve performance metrics.

On the other hand, LOSO cross-validation applied in this chapter isolates one student's data entirely for testing in each iteration, while the remaining students' data is used for training. This approach ensures that the model does not see any part of the test student’s data during training to get a strict evaluation of the model’s generalizability to new subjects. However, this can lead to imbalance in the test set, especially when individual students show behaviours that are not well-represented in the training data. This imbalance can cause the model to struggle to predict loneliness for students whose behavioural patterns are underrepresented in the training set. This test set imbalance and elimination of data leakage in this chapter result in lower performance metrics compared to Chapter 4 results. Future work should consider applying LOSO in Chapter 4 to ensure a fair comparison across approaches.

Collectively all these findings directly address our core research questions which aimed to understand the interconnected relationship between behaviours extracted through passive sensing with loneliness and depression. By investigating these associations, we have gained a holistic picture of the specific factors that contribute to these two conditions among students. Our primary aim was to explore the role of behavioural patterns in the context of loneliness and depression. As discussed in Chapter 1 and 2 that existing research has primarily examined these features in relation to general mental health conditions, we have shown that these same features interact in distinct ways when examining loneliness versus depression. The findings of this chapter support and expand upon the previous literature reviewed in Chapter 2, which emphasized the role of behavioural markers in mental health detection. While our study confirms the importance of features like phone usage, sleep duration, and physical activity, our findings highlight the need for a more nuanced interpretation of these features, particularly when distinguishing between loneliness and depression. The results presented in this chapter show that while passive sensing features are powerful tools for detecting mental health issues, they must be interpreted in context to accurately differentiate between specific conditions like loneliness and depression. This highlights the need of further research into how contextual and emotional states modulate these behavioural patterns differently in specific mental health conditions.

While our analyses provides important aspects about the relationship between loneliness and depression and the potential mediating role of behaviours but it does not establish causality between loneliness and depression. The observed relationships should be interpreted as associations that need further investigation through longitudinal or experimental studies to confirm the directionality and causal nature of these effects.

\section{Conclusions and Limitations}
This chapter investigated the relationship between loneliness and depression using passive sensing data. Below are the key findings from this chapter that address the key research questions presented at the beginning of this chapter:

\begin{itemize}
\item We have found distinct behavioural patterns associated with loneliness and depression. Higher phone usage was associated with increased loneliness but decreased depression. Location-based features showed opposite trends for loneliness and depression, with more location transitions associated with higher loneliness but lower depression. Physical activity and sleep duration were positively associated with reduced likelihood of both conditions. These findings highlight the nuanced differences in behavioural manifestations of loneliness and depression that emphasize the importance of considering these conditions separately in intervention strategies.

\item The mediation analysis found significant indirect effects between loneliness and depression through different behavioural features. Phone usage duration, number of unique places visited, physical activity duration, and sleep duration were identified as significant mediators in both directions. These findings show a nuanced relation between loneliness and depression, mediated by different behaviours. For instance, while increased phone usage might increase the effect of depression on loneliness, it appears to mitigate the impact of loneliness on depression.

\item We have shown the high predictive power of passive sensing data in identifying students experiencing loneliness or depression. The XGBoost model achieved the highest accuracy for both loneliness (82.43\%) and depression (79.43\%) predictions. This shows that behavioural features derived from passive sensing data, combined with standardized scales can effectively identify lonely or depressed students. The strong performance of these models highlights the potential of passive sensing in early detection and intervention strategies for student mental health.

\end{itemize}

We will be discussing detailed limitations along with future work in the next chapter, but below are some key limitations that we want to acknowledge:

\begin{itemize}

\item As mentioned in earlier chapters as well, these findings are limited to a single student population. Therefore, these findings should be interpreted within this context and not generalized to other populations or broader age groups.

\item The interpretation of behavioural features (e.g., phone usage) may vary among individuals. For instance, high phone usage might indicate social engagement for some but signify isolation for others as we have explained in the discussion section.

\item While significant associations were found between loneliness, depression and behavioural features, our study did not infer causality. Longitudinal studies or experimental designs would be necessary to establish causal relationships and better understand the directional influences between these conditions through behavioural patterns.

\end{itemize}
