# 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)
CensusSchool <- filter(CensusSchool, Sleep_Hours_Schoolnight <= 16*7)
CensusSchool <- filter(CensusSchool, Gender!= "NA")
gf_jitter(Sleep_Hours_Schoolnight ~ Gender, data = CensusSchool,, color = "blue", width = .2)
sleep.model <- lm(Sleep_Hours_Schoolnight ~ Gender, data = CensusSchool)
sleep.model
CensusSchool <- filter(CensusSchool, Sleep_Hours_Schoolnight <= 16*7)
CensusSchool <- filter(CensusSchool, Gender!= "NA")
lm(Sleep_Hours_Schoolnight ~ NULL, data = CensusSchool) -> Empty_Model
predict(Empty_Model) -> CensusSchool$Empty.pred
head(CensusSchool)
gf_jitter(Sleep_Hours_Schoolnight ~ Gender, data = CensusSchool, width = .2)%>%
gf_jitter(predict(sleep.model) ~ Gender, color = "blue", height = 0)
supernova(sleep.model)
confint(sleep.model)
sdopre <- do(1000) * PRE(Sleep_Hours_Schoolnight ~ shuffle(Gender), data = CensusSchool)
gf_histogram(~ PRE, data = sdopre) %>%
gf_point(0 ~ PRE(Sleep_Hours_Schoolnight ~ Gender, data = CensusSchool))