Ashley's Deepnote
ashley marie/
CensusSchool <- read.csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vSVaWnM4odSxy0mlnhWvvGbeLtiKoZmsbqC6KLzXtBOjQfrF9EVKuX4RVh3XbP3iw/pub?gid=2100178416&single=true&output=csv", header = TRUE) head(CensusSchool) head(select(CensusSchool, Ageyears, Favorite_Season))
Can a students favorite season be caused by how old they are ?
My initial hypothesis is that a high school students favorite season will NOT be caused on how old they are. Students constantly change their mind or may choose a random season thinking that, that season is their "favorite", also known as other stuff. The outcome I am trying to explain is a students Ageyears and will be using Favorite_Season variable to predict it.
Ageyears= Favorite_Season + Other Stuff
To further explain my hypothesis, I am going to be using the data of the study conducted by an American high school class project. This high school project collected data from 10,113 high school students in the U.S. who completed an online questionnaire. As a part of their statistics course project, their data frame contained 60 variables.
The two variables that I will be focusing on is "Favorite_Season" and "Ageyears"
To focus on the two variables of Interest, I have filtered out "NA" from Seasons and only included students ages 15 to 18. I created a new data frame called "CensusSchool2"
The visualization that best conveys the variability in my study would be the use of a bar graph.
Based on these visualizations, my initial hypothesis was incorrect. Meaning there is a correlation between favorite seasons in Age years. I was also surprised to discover that the each season was most popular in age 17. It is possible that favorite seasons in age years along with other stuff explain which season was most favorable.
filter(CensusSchool, Ageyears<=18, Ageyears>14, Favorite_Season!="NA", Ageyears!="16.58", Ageyears!="17.5", Ageyears!="15.5", Ageyears!="16.3")-> CensusSchool2 gf_bar(~ Ageyears, data = CensusSchool2, color = ~ Favorite_Season) %>% gf_facet_grid(Favorite_Season ~ .)
mygraph <- gf_bar(~ Ageyears, data = CensusSchool2, color = ~ Favorite_Season) %>% gf_facet_grid(Favorite_Season ~ .) mygraph + coord_flip()
First off, I created season.model to predict: if Ageyears a student has may have an impact on their Favorite Season. This model gave us a predicted Ageyears depending on Favorite Season.
16:mean of Ageyears in Fall -0.02:difference from mean of Ageyears in Fall to Spring -0.01:difference from mean of Ageyears in Fall to Summer -0.03:difference from mean of Ageyears in Fall to Winter
By looking at the graph it seems that neither the empty.model or the season.model do not explain variation. The season.model seem to be at the same line as the empty.model.
lm(Ageyears ~ Favorite_Season, data = CensusSchool2) -> season.model predict(season.model) -> CensusSchool2$pred gf_boxplot(Ageyears ~ Favorite_Season, data = CensusSchool2, alpha = .2, size = 1, color = ~Favorite_Season) %>% gf_point(pred ~ Favorite_Season, color = "green")
lm(Ageyears ~ Favorite_Season, data = CensusSchool2) supernova(season.model)
empty_model <- lm(Ageyears ~ NULL, data = CensusSchool2) season.model <- lm(Ageyears ~ Favorite_Season, data = CensusSchool2) gf_boxplot(Ageyears ~ Favorite_Season, data = CensusSchool2, alpha = .2, size = 2, color = ~Favorite_Season) %>% gf_theme(theme_bw()) %>% gf_jitter(predict(empty_model) ~ Favorite_Season, color = "purple", height = 0, size = 2) %>% gf_jitter(predict(season.model) ~ Favorite_Season, color = "grey", height = 0, size = 2)