SET-UP
setwd("~/1. School/3rd Year/2nd sem/Statistical Software/Midterm Exam (bfrss.RData)")
LOAD PACKAGES
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
library(magrittr)
## Warning: package 'magrittr' was built under R version 4.0.5
LOAD DATA
load("brfss2013.RData")
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 function summary in R?
1.2 Provide statistics using the function summary without NA’s and data with at most 10 hours of sleep.
Research Question 2: What analysis can you share on the Perception of others to the Depressive Disorder of the Respondents with those having less than 6 hours of sleep on average?
Research Question 3: What insights can you provide in comparing between having less than 6 hours of sleep and having 6 to 10 hours of sleep that were perceived with depression disorder (addepev2)?
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 function summary in R?
Using the function summary in R on the variable “sleptim1”.
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
Using the function summary in R on the variable “addepev2”.
summary(brfss2013$addepev2)
## Yes No NA's
## 95779 393707 2289
1.2 Provide statistics using the function summary without NA’s and data with at most 10 hours of sleep.
Using the function summary without NA’s on the variable “addepev2”
WoNaSleep<-brfss2013%>%
filter(!is.na(addepev2))
summary(WoNaSleep$addepev2)
## Yes No
## 95779 393707
Using the function summary without NA’s on the variable “sleptim1”
WoNaSleep<-brfss2013%>%
filter(!is.na(sleptim1))
summary(WoNaSleep$sleptim1)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 6.000 7.000 7.052 8.000 450.000
Using the function summary in R with at most 10 hours of sleep.
AtMost10hrsSleep <- WoNaSleep%>%
filter(sleptim1<=10)
summary(AtMost10hrsSleep$sleptim1)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 6.000 7.000 6.976 8.000 10.000
Discussion:
As you can see the above result,for the variable “addepev2”, the statistics are the same. But, for the variable “sleptim1” almost of the result are the same except for the maximum value. This means that the above result shows that there are many observations with at most 10 hours on average sleep.
Research Question 2: What analysis can you share on the Perception of others to the Depressive Disorder of the Respondents with those having less than 6 hours of sleep on average?
sl_dep5<-WoNaSleep%>%
filter(!is.na(sleptim1),!is.na(addepev2),sleptim1<6)%>%
group_by(addepev2)%>%
summarise(count=n())
sl_dep5
## # A tibble: 2 x 2
## addepev2 count
## <fct> <int>
## 1 Yes 17828
## 2 No 34275
ggplot(data=sl_dep5,aes(x=addepev2,y=count))+geom_bar(stat="identity",color="black",fill="blue")+xlab("DEPPRESSIVE DISORDER for PEOPLE having LESS THAN 6 hours of SLEEP on AVERAGE")+ylab("Number of US Citizens")
17828/(17828+34275)
## [1] 0.3421684
Discussion:
As shown in the graph, 34.21684 % are having depressive disorder being perceived by others with those having less than 6 hours of sleep. This result means that 1 out of 3 of those who sleep less than 6 hours on average is being perceived by others having a depressive disorder.
Research Question 3: What insights can you provide in comparing between having less than 6 hours of sleep and having 6 to 10 hours of sleep that were perceived with depression disorder (addepev2)?
sl_dep6 <- AtMost10hrsSleep%>%
filter(!is.na(sleptim1),!is.na(addepev2),sleptim1>5)%>%
group_by(addepev2)%>%
summarise(count=n())
sl_dep6
## # A tibble: 2 x 2
## addepev2 count
## <fct> <int>
## 1 Yes 73771
## 2 No 350259
ggplot(data=sl_dep6,aes(x=addepev2,y=count))+geom_bar(stat="identity",color="black",fill="yellow")+xlab("DEPPRESSIVE DISORDER for PEOPLE having 6 to 10 hours AVERAGE SLEEP")+ylab("Number of US Citizens ")
73771/(73771+350259)
## [1] 0.1739759
Discussion:
As found in Research Question 3, 17.39759% are having the depressive disorder as being perceived by others with those having 6 to 10 hours of average sleep. This implies that 1 out of 4 of those who sleep 6 to 10 hours on average are being perceived by others having a depressive disorder. Comparing this result to the result in Research Question 2, the result in Research Question 3 shows that having 6-10 hours on average sleep has a lesser depressive disorder as perceived by others. As you can see, the result in Research Question 3 is half of the result than the result in Research Question 2. From the above results, it further means that having between 6-10 hours on average sleep could lower the depressive disorder as perceived by others.