11.15 Chapter 11 Review Questions 2
Audiences love disaster movies in which the world ends and a hero saves the day. But how scared are people, really, of natural disasters?
In 2015, when the earthquake disaster movie "San Andreas" came out,
the news website FiveThirtyEight commissioned a poll to survey
participants about their fears, experience, and knowledge of
earthquakes, in addition to collecting demographic information related
to age, gender, region, and household income. The
san_andreas data frame is a modified version of the results
of this survey.
The san_andreas data frame consists of 978 responses to
the following survey items:
worry_generalIn general, how worried are you about earthquakes? (measured on a 5-item scale from 1 to 5, with 5 being most worried)worry_bigoneHow worried are you about the "Big One," a massive, catastrophic earthquake? (measured on a 5-item scale from 1 to 5, with 5 being most worried)will_occurDo you think the "Big One" will occur in your lifetime? (true = yes, false = no)experienceHave you ever experienced an earthquake? (no; yes, one or more minor ones; yes, one or more major ones)preparedHave you or anyone in your household taken any precautions for an earthquake (packed an earthquake survival kit, prepared an evacuation plan, etc.)? (true = yes, false = no)fam_san_andreasHow familiar are you with the San Andreas Fault line? (measured on a 5-item scale from "not at all familiar" to "extremely familiar")fam_yellowstoneHow familiar are you with the Yellowstone Supervolcano? (measured on a 5-item scale from "not at all familiar" to "extremely familiar")femaleGender (true = female; false = male)regionUS Region (region of the United States in which the participant lives)ageAge (in years)incometotal household income (in thousands of dollars)
require(coursekata)
link <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vSZozH-r8y8XkIQ71eLTKL94R8Unkw41KqCJFmbvRlU-jcphybc4X_WVNZTvAH1_-4l4tx7wWSIH0Rk/pub?output=csv"
san_andreas <- read.csv(link, header=TRUE)
san_andreas$experience <- as.factor(san_andreas$experience)
san_andreas$will_occur <- as.factor(san_andreas$will_occur)
san_andreas$worry_general <- recode(san_andreas$worry_general, "Not at all worried" = 1, "Not so worried" = 2, "Somewhat worried" = 3, "Very worried" = 4, "Extremely worried"= 5)
san_andreas$worry_bigone <- recode(san_andreas$worry_bigone, "Not at all worried" = 1, "Not so worried" = 2, "Somewhat worried" = 3, "Very worried" = 4, "Extremely worried"= 5)
san_andreas$experience <- factor(san_andreas$experience, levels = c("No", "Yes, one or more minor ones", "Yes, one or more major ones"))
san_andreas <- na.omit(san_andreas)
# run your code hererequire(coursekata)
link <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vSZozH-r8y8XkIQ71eLTKL94R8Unkw41KqCJFmbvRlU-jcphybc4X_WVNZTvAH1_-4l4tx7wWSIH0Rk/pub?output=csv"
san_andreas <- read.csv(link, header=TRUE)
san_andreas$experience <- as.factor(san_andreas$experience)
san_andreas$will_occur <- as.factor(san_andreas$will_occur)
san_andreas$worry_general <- recode(san_andreas$worry_general, "Not at all worried" = 1, "Not so worried" = 2, "Somewhat worried" = 3, "Very worried" = 4, "Extremely worried"= 5)
san_andreas$worry_bigone <- recode(san_andreas$worry_bigone, "Not at all worried" = 1, "Not so worried" = 2, "Somewhat worried" = 3, "Very worried" = 4, "Extremely worried"= 5)
san_andreas$experience <- factor(san_andreas$experience, levels = c("No", "Yes, one or more minor ones", "Yes, one or more major ones"))
san_andreas <- na.omit(san_andreas)
# Box Plots and Histograms
gf_boxplot(worry_bigone ~ experience, data = san_andreas)
gf_histogram(~worry_bigone, data = san_andreas, bins = 5) %>%
gf_facet_grid(experience~.)
# Write some code to fit and save exp_modelrequire(coursekata)
link <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vSZozH-r8y8XkIQ71eLTKL94R8Unkw41KqCJFmbvRlU-jcphybc4X_WVNZTvAH1_-4l4tx7wWSIH0Rk/pub?output=csv"
san_andreas <- read.csv(link, header=TRUE)
san_andreas$experience <- as.factor(san_andreas$experience)
san_andreas$will_occur <- as.factor(san_andreas$will_occur)
san_andreas$worry_general <- recode(san_andreas$worry_general, "Not at all worried" = 1, "Not so worried" = 2, "Somewhat worried" = 3, "Very worried" = 4, "Extremely worried"= 5)
san_andreas$worry_bigone <- recode(san_andreas$worry_bigone, "Not at all worried" = 1, "Not so worried" = 2, "Somewhat worried" = 3, "Very worried" = 4, "Extremely worried"= 5)
san_andreas$experience <- factor(san_andreas$experience, levels = c("No", "Yes, one or more minor ones", "Yes, one or more major ones"))
san_andreas <- na.omit(san_andreas)
exp_model <- lm(worry_bigone ~ experience, data = san_andreas)
# Run this code
pairwise(exp_model)