# Run this code to load the required packages
suppressMessages(suppressWarnings(suppressPackageStartupMessages({
library(mosaic)
library(supernova)
library(Lock5withR)
})))
# Adjust the plots to be a bit smaller
options(repr.plot.width = 6, repr.plot.height = 4)
CensusSchool <- read.csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vSVaWnM4odSxy0mlnhWvvGbeLtiKoZmsbqC6KLzXtBOjQfrF9EVKuX4RVh3XbP3iw/pub?gid=2100178416&single=true&output=csv", header = TRUE)
str(CensusSchool)
In the data provided by the United States Census at school questionnaire, the dataset comes
from a sample of 10,113 high school students at high schools in the United States. The students
completed this questionnaire as part of their statistics course. And now a researcher named Anthony
Gonzalez came across this data since he is a person that grew up spending alot of time with his
family he wonders if people from the questionnaire also spent more time with their family if they
prefer to be happy. So he claims that if a student chose that his preferred status was Happy then
that means they were most likely to spend more time with their family. How much time a student spends
doing things with their family model it can determine whether their preferred status should be happy
rich, famous, or healthy. In this research I am using the explanatory variable of Preferred_Status
to prove someones outcome variable which is Doing_Things_With_Family_Hours. This research questions
is important because we are trying to figure out if someone that spends more time with their family
is more likely to be happy according to my hypothesis.
Doing_Things_With_Family_Hours = Preferred Status + Other Stuff
CensusSchool <- filter(CensusSchool, Doing_Things_With_Family_Hours <= 16*7)
CensusSchool <- filter(CensusSchool, Preferred_Status!= "NA")
gf_histogram(~Doing_Things_With_Family_Hours, data = CensusSchool)%>%
gf_facet_grid(Preferred_Status ~ .)
Hours.Model <- lm(Doing_Things_With_Family_Hours ~ Preferred_Status, data = CensusSchool)
Hours.Model
CensusSchool <- filter(CensusSchool, Doing_Things_With_Family_Hours <= 16*7)
CensusSchool <- filter(CensusSchool, Preferred_Status!= "NA")
lm(Doing_Things_With_Family_Hours ~ NULL, data = CensusSchool) -> Empty_model
predict(Empty_model) -> CensusSchool$Empty.Pred
head(CensusSchool)
gf_jitter(Doing_Things_With_Family_Hours ~ Preferred_Status, data = CensusSchool) %>%
gf_jitter(predict(Hours.Model ~ Preferred_Status, color = "dodgerblue", height = 0))
supernova(Hours.Model)