Course Outline

list Items Test Book

Book
  • Items Test Book

ckcode ⌲ chapter-x2-exploring-to-modeling

require(coursekata) # Create a histogram of PriceK from the Ames data set gf_histogram(~ PriceK, data = Ames) ex() %>% check_function(., "gf_histogram") %>% { check_arg(., "object") %>% check_equal() check_arg(., "data") %>% check_equal() }
CK Code: X2_Code_Relationships_01
require(coursekata) # replace the . with Floors gf_histogram(~ PriceK, data = Ames) %>% gf_facet_grid(Neighborhood ~ .) # replace the . with Floors gf_histogram(~ PriceK, data = Ames) %>% gf_facet_grid(Neighborhood ~ Floors) ex() %>% check_function(., "gf_histogram") %>% { check_arg(., "object") %>% check_equal() check_arg(., "data") %>% check_equal() }
CK Code: X2_Code_Visualizing_01
require(coursekata) gf_boxplot(PriceK ~ Neighborhood, data = Ames) gf_boxplot(PriceK ~ Neighborhood, data = Ames) %>% gf_jitter() ex() %>% check_function("gf_jitter") %>% check_result() %>% check_equal()
CK Code: X2_Code_TwoVariable_01
require(coursekata) # make a scatterplot to explore the relationship between PriceK and HomeSizeK gf_point(PriceK ~ HomeSizeK, data = Ames) ex() %>% check_function("gf_point") %>% check_result() %>% check_equal()
CK Code: X2_Code_TwoVariable_02
require(coursekata) # use R as a calculator to find the mean of these 5 houses # we have started it out for you by summing the prices together (50 + 50 + 50 + 100 + 200) (50 + 50 + 50 + 100 + 200) / 5 ex() %>% check_output_expr("(50 + 50 + 50 + 100 + 200) / 5")
CK Code: X2_Code_Mean_01
require(coursekata) # here's code to find empty model using favstats() favstats(~ PriceK, data = Ames) # write code to find the empty model using lm() # here's code to find empty model using favstats() favstats(~ PriceK, data = Ames) # write code to find the empty model using lm() lm(PriceK ~ NULL, data = Ames) ex() %>% { check_function(., "favstats") %>% check_result() %>% check_equal() check_function(., "lm") %>% check_result() %>% check_equal() }
CK Code: X2_Code_Fitting_01
require(coursekata) # this saves the empty model of PriceK empty_model <- lm(PriceK ~ NULL, data = Ames) # write code to print the contents of empty_model # this saves the empty model of PriceK empty_model <- lm(PriceK ~ NULL, data = Ames) # write code to print the contents of empty_model empty_model ex() %>% check_output_expr('empty_model')
CK Code: X2_Code_Fitting_02
require(coursekata) # this saves the empty model empty_model <- lm(PriceK ~ NULL, data = Ames) gf_jitter(PriceK ~ Neighborhood, data = Ames, width = .1) # this saves the empty model empty_model <- lm(PriceK ~ NULL, data = Ames) gf_jitter(PriceK ~ Neighborhood, data = Ames, width = .1) %>% gf_model(empty_model) ex() %>% check_function("gf_model") %>% { check_arg(., "model") %>% check_equal() check_result(.) %>% check_equal() }
CK Code: X2_Code_Fitting_03
require(coursekata) empty_model <- lm(PriceK ~ NULL, data = Ames) # generate predictions from this model empty_model <- lm(PriceK ~ NULL, data = Ames) # generate predictions from this model predict(empty_model) ex() %>% check_output_expr("predict(empty_model)")
CK Code: X2_Code_Quantifying_01
require(coursekata) empty_model <- lm(PriceK ~ NULL, data = Ames) # generate residuals from this model’s predictions empty_model <- lm(PriceK ~ NULL, data = Ames) # generate residuals from this model’s predictions resid(empty_model) ex() %>% check_output_expr("resid(empty_model)")
CK Code: X2_Code_Quantifying_02
require(coursekata) empty_model <- lm(PriceK ~ NULL, data = Ames) # saves the predictions and residuals from the empty model Ames$empty_predict <- predict(empty_model) Ames$empty_resid <- resid(empty_model) # this will show us the first 6 rows of PriceK # modify this code also show prediction and residual variables head(select(Ames, PriceK)) # saves the predictions and residuals from the empty model Ames$empty_predict <- predict(empty_model) Ames$empty_resid <- resid(empty_model) # this will show us the first 6 rows of PriceK # modify this code also show prediction and residual variables head(select(Ames, PriceK, empty_predict, empty_resid)) ex() %>% check_function("head") %>% check_result() %>% check_equal()
CK Code: X2_Code_Quantifying_03
require(coursekata) # don't delete this part empty_model <- lm(PriceK ~ NULL, data = Ames) Ames$empty_resid <- resid(empty_model) # this creates the squared residuals Ames$empty_resid_sqrd <- Ames$empty_resid^2 # write code to sum these squared residuals # this create the squared residuals Ames$empty_resid_sqrd <- Ames$empty_resid^2 # write code to sum these squared these residuals sum(Ames$empty_resid_sqrd) ex() %>% check_function("sum") %>% check_result() %>% check_equal()
CK Code: X2_Code_Quantifying_04
require(coursekata) # we’ve created the empty model empty_model <- lm(PriceK ~ NULL, data = Ames) # generate the ANOVA table # we’ve created the empty model empty_model <- lm(PriceK ~ NULL, data = Ames) # generate the ANOVA table supernova(empty_model) ex() %>% check_function("supernova") %>% check_result() %>% check_equal()
CK Code: X2_Code_Beauty_01

Responses