###Load packages
library(ggplot2)
library(dplyr)
##
## 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
###Load data Make sure your data and R Markdown files are in the same directory. When loaded your data file will be called brfss2013. Delete this note when before you submit your work.
load("brfss2013.RData")
Part 1: Data The data taken by BRFSS was collected over the phone. BRFSS were simply observers to this data and did not conduct an experiment, therefore any conclusions we come to can only be correlations and we will not be able to make any causal claims.
Additionally, as the data was collected over the phone, we have to assume that the interviews exceeded a certain income level in which the respondents could afford a working phone. This may mean that important data is missed regarding the health status/conditions of lower-income people.
###Part 2: Research questions Research question 1:
Is there a relationship between smoking 100 or more cigarettes and exercising in the last 30 days? (2 variables)
I thought this question would be interesting because I expected there to be a negative correlation between smoking and exercise.
Research question 2:
Is there a relationship between the mentally unhealthy days someone experiences, the number of depressed day someone experiences and whether they have any outstanding medical bills? (3 variables)
This question was interesting for me because I thought that there would be a strong agreement between the number of mentally unhealthy days and the number of depressed days. I also wondered whether having outstanding medical bills (financial issues) could be a factor.
Research question 3:
Is there a relationship between someone’s gender, their marital status and whether they rent or own their home? (3 variables)
I thought this would be interesting as only one person from each household gets asked all of the questions from the survey, therefore we could understand whether gender and marital status are correlated with owning a house.
Research question 1:
brfss2013.exersmok <- brfss2013[,c("exerany2", "smoke100")]
brfss2013.sub_exersmok <- brfss2013.exersmok[ complete.cases(brfss2013.exersmok),]
p <- ggplot(brfss2013.sub_exersmok, aes(x=smoke100, fill = exerany2)) +
geom_bar(position="dodge")
p + ggtitle("Do people that exercise also smoke?") +
xlab("Smoke over 100 cigarettes") + ylab("No. of people exercised in last 30 days") + labs(fill="Exercise")
As both variables are categorical, it is easier to visualize the data rather than calculate.
From the plots we can see that the vast majority of people that responded to the exercise question do actually exercise. This could possibly be a biased answer though, as some may not wish to admit that they do not exercise to a stranger on the phone.
As expected, the majority of people that exercise do not smoke. Interestingly, the amount of people that do not exercise and do not smoke, does not greatly differ from the people that do not exercise and do smoke. This could indicate that not exercising is independent to whether someone smokes or not.
Research question 2:
y <- ifelse (brfss2013$qlmentl2 == brfss2013$menthlth, TRUE, FALSE)
summary (y)
## Mode FALSE TRUE NA's
## logical 185 294 491296
294/(294+185)
## [1] 0.6137787
brfss2013.health <- brfss2013[,c("qlmentl2", "menthlth", "medbills")]
brfss2013.sub_health <- brfss2013.health[ complete.cases(brfss2013.health),]
q <- ggplot(brfss2013.sub_health, aes(x=qlmentl2, y=menthlth, colour=medbills)) + geom_point(alpha=1)
q + xlab("No. of depressed days") + ylab("No. of mentally unhealthy days") +
labs(fill="Medical Bills")
My expectation was that there would be equal number of days reported depressed and mentally unhealthy (as I would consider them to be similar questions). This does look to be the case for the majority of respondents considering that roughly 61% of people that answered both questions reported to have the same number of depressed and mentally unhealthy days.
From the scatter plot, we can also see that people who do have medical bills tend to not have more than 15 depressed days, but can have up to 30 mentally unhealthy days. This could be for a number of reasons and the plot is not strong enough to allow us to make any assumptions.
Research question 3:
brfss2013.gender <- brfss2013[,c("sex", "renthom1", "marital")]
brfss2013.sub_gender <- brfss2013.gender[ complete.cases(brfss2013.gender) & !(brfss2013$renthom1 %in% c("Other arrangement")),]
g <- ggplot(brfss2013.sub_gender, aes(x=sex, fill = marital)) +
geom_bar(position="dodge") + facet_wrap( ~ renthom1, ncol=2)
g + xlab(" ") + ylab("No. of people") + labs(fill="Marital status")
From the graph we can tell that the majority of people that responded to the questions owned a house. This data may change if the survey was to be done face-to-face and would therefore not exclude people that were unable to afford a phone.
Interestingly, we see that married couples tend to own their homes instead of renting. Also interestingly, widowed women own significantly more houses than widowed men.