Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💤 Sleep, Health, and Lifestyle Analysis

This project analyzes how various health and lifestyle factors affect sleep quality and disorders using data visualization and statistical techniques in R. The goal is to demonstrate a clear and thorough data science process, including preprocessing, exploratory data analysis (EDA), and multivariate insights.


📁 Dataset

Source: Sleep Health and Lifestyle Dataset (Kaggle)
Size: 374 records of adults
Features include:

  • Age, Gender, BMI Category
  • Sleep Duration, Quality of Sleep, Sleep Disorder
  • Stress Level, Physical Activity, Daily Steps
  • Blood Pressure, Heart Rate

⚙️ 1. Data Preprocessing

  • Converted Blood Pressure into Systolic and Diastolic columns.
  • 💡 Note: The Blood Pressure column was initially in 'systolic/diastolic' format and was split into two numeric columns: Systolic and Diastolic.

  • Checked and handled missing values.
  • Ensured appropriate data types for each column.

📊 2. Exploratory Data Analysis (EDA)

🔹 Univariate Analysis

  • Age Distribution
    Most participants are between 20 and 70 years old.
    Age_distribution

  • Sleep Duration
    Sleep duration mostly ranges between 5 to 9 hours.
    Sleep_duration_distribution

  • BMI Categories
    Around 50% have normal BMI, and 40% are overweight.
    BMI_bar_plot


🔹 Bivariate Analysis

Categorical vs Numerical

  • BMI Category vs Sleep Quality
    People with normal BMI tend to have better sleep quality.
    BMI_and_Sleep_Quality

  • BMI vs Age
    Overweight individuals are more likely in the middle-aged group.
    BMI_and_Age

Numeric vs Numeric

  • Pairplot
    To explore pairwise relationships among numeric features.
    Pairplot

  • Correlation Matrix
    Showed that sleep quality is positively correlated with sleep duration and negatively correlated with stress level.
    correlation_matrix

  • Sleep Duration vs Sleep Quality
    Confirmed linear relationship.
    SleepQuality_and_SleepDuration


🔺 3. Multivariate Analysis

Explored interactions between 3+ features using colored boxplots and faceted visualizations.

  • Stress Level vs Sleep Duration (by Sleep Disorder)
    High stress levels are linked to shorter sleep durations, especially among those with sleep disorders.
    Stress_and_SleepDuration

  • Blood Pressure & Heart Rate by Sleep Disorder
    Participants with sleep disorders generally have elevated blood pressure and heart rate.
    BloodPressure_HeartRate_SleepDisorder

  • Daily Steps vs Sleep Quality (by Sleep Disorder)
    In insomnia patients, higher daily steps correlated with better sleep quality, unlike those without disorders.
    DailySteps_and_SleepQuality


5. Dimensionality Reduction: PCA

To reduce complexity and explore latent patterns in numeric variables, PCA (Principal Component Analysis) was applied.

  • Features Used: Age, Sleep Duration, Sleep Quality, Stress Level, Physical Activity Level, Daily Steps, Heart Rate, Systolic and Diastolic Blood Pressure.
  • The data was standardized before applying PCA.
  • The scree plot showed that the first 2 principal components explain over X% of the total variance.

The PCA biplot reveals strong contribution from stress level and sleep quality to the first component, while heart rate and blood pressure load more strongly on the second component.

PCA_biplot

✅ Key Insights

  • Sleep quality improves with longer sleep duration and lower stress levels.
  • Overweight and obese individuals report lower sleep quality.
  • Sleep disorders are associated with higher heart rate and blood pressure.
  • Physical activity seems to help sleep quality for insomnia sufferers.

📦 Tools Used

  • Language: R
  • Libraries:
    ggplot2, dplyr, tidyr, GGally, ggcorrplot, readr

🙏 Acknowledgements


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages