Set-up

setwd("C:/1. Bryle Documents/Statistical Software")

Load Packages

library("magrittr")
## Warning: package 'magrittr' was built under R version 4.0.5
library("dplyr")
## Warning: package 'dplyr' was built under R version 4.0.5
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library("ggplot2")
## Warning: package 'ggplot2' was built under R version 4.0.5

Load Data

load("brfss2013.RData")

Research Problems :

Research Question 1:

Exploratory Data Analysis and some statistics on the variables “sleptim1” and “addepev2” in terms of the following:

1.1 What are its statistics using the fucntionsummary in R?

summary(brfss2013$sleptim1)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   0.000   6.000   7.000   7.052   8.000 450.000    7387
summary(brfss2013$addepev2)
##    Yes     No   NA's 
##  95779 393707   2289

1.2 Provide statistics using the function summary without summary without NA’s and data with at most 10 hours of sleep.

y<- na.omit(brfss2013$addepev2)
summary(y)
##    Yes     No 
##  95779 393707
Whout_sleptim1<-brfss2013%>%
  filter(!is.na(sleptim1))
  summary(Whout_sleptim1$sleptim1)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   6.000   7.000   7.052   8.000 450.000
ten<- Whout_sleptim1%>%
  filter(sleptim1<=10)
  summary(ten$sleptim1)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   6.000   7.000   6.976   8.000  10.000

Research Question 2:

What analysis can you share on the Perception on others to the Depressive Disorder of the Respondents wth those having less than 6 hours of sleep on average?

a <- Whout_sleptim1%>%
  filter(!is.na(sleptim1),!is.na(addepev2),sleptim1<6)%>%
  group_by(addepev2)%>%
  summarise(count=n())

It means that 34.21% are those having depression as perceived by others having less than 6 hours of sleep.

ggplot(data=a,aes(x=addepev2,y=count))+geom_bar(stat="identity",color='red',fill='orange')+xlab("Depressive Disorder for people having at most 5 hours of average sleep")+ylab("Number of US citizens ")

(17828/(17828+34275))
## [1] 0.3421684

Research Question 3:

What insights can you provide in comparing between having less than 6 hours of sleep and having of sleep that were perceived with depression disorder (addepev2)?

b <- ten %>%
  filter(!is.na(sleptim1),!is.na(addepev2),sleptim1>5)%>%
  group_by(addepev2)%>%
  summarise(count=n())
ggplot(data=b,aes(x=addepev2,y=count))+geom_bar(stat="identity",color='red',fill='blue')+xlab("Depressive Disorder for people having 6 to 10 hours average sleep")+ylab("Number of US citizens ")

(73771/(73771+350259))
## [1] 0.1739759

This shows that the average sleep range from 6 to 10 hours have lower depression disorders as perceived by other and thus lower depression disorder.