Course Outline

list Items Test Book

Book
  • Items Test Book

ckcode ⌲ chapter-d4-more-models-with-interactions

require(coursekata) # add color to see how YearBuilt relates to this data gf_point(PriceK ~ HomeSizeK, data = Ames) # add color to see how YearBuilt relates to this data gf_point(PriceK ~ HomeSizeK, data = Ames, color = ~YearBuilt) ex() %>% check_function("gf_point") %>% { check_arg(., "object") %>% check_equal() check_arg(., "data") %>% check_equal() check_arg(., "color") %>% check_equal() }
CK Code: D4_Code_TwoPred_01
require(coursekata) # fit and save the interaction model interaction_model <- # add the model to this scatterplot gf_point(PriceK ~ HomeSizeK, data = Ames, color = ~YearBuilt) # fit and save the interaction model interaction_model <- lm(PriceK ~ YearBuilt*HomeSizeK, data = Ames) # add the model to this scatterplot gf_point(PriceK ~ HomeSizeK, data = Ames, color = ~YearBuilt) %>% gf_model(interaction_model) ex() %>% check_function("gf_model") %>% { check_arg(., "object") %>% check_equal() check_arg(., "model") %>% check_equal() }
CK Code: D4_Code_Fitting_01
require(coursekata) # find the best-fitting parameter estimates for the interaction model # find the best-fitting parameter estimates for the interaction model lm(PriceK ~ YearBuilt * HomeSizeK, data = Ames) # or alternatively: lm(PriceK ~ HomeSizeK * YearBuilt, data = Ames) ex() %>% check_or( check_function(., "lm") %>% check_result() %>% check_equal(), override_solution(., "lm(PriceK ~ HomeSizeK * YearBuilt, data = Ames)") %>% check_function("lm") %>% check_result() %>% check_equal() )
CK Code: D4_Code_Interpreting_01
require(coursekata) # generate the ANOVA table for the interaction model # (no models have been pre-saved for you) # generate the ANOVA table for the interaction model # (no models have been pre-saved for you) supernova(lm(PriceK ~ YearBuilt * HomeSizeK, data = Ames)) # or alternatively: supernova(lm(PriceK ~ HomeSizeK * YearBuilt, data = Ames)) ex() %>% check_or( check_function(., "supernova") %>% check_result() %>% check_equal(), override_solution(., "supernova(lm(PriceK ~ HomeSizeK * YearBuilt, data = Ames))") %>% check_function("supernova") %>% check_result() %>% check_equal() )
CK Code: D4_Code_Comparing_01
require(coursekata) # run this first before modifying gf_jitter(tip_percent ~ condition, data = tip_exp, width = .1, color = ~gender) # run this first before modifying gf_jitter(tip_percent ~ condition, data = tip_exp, width = .1, color = ~gender) %>% gf_facet_grid(. ~ gender) ex() %>% check_function("gf_facet_grid") %>% { check_arg(., "object") %>% check_equal() check_arg(., 2) %>% check_equal() }
CK Code: D4_Code_Interactions_01
require(coursekata) # fit and save the interaction model interaction_model <- # add code to put the interaction model on this plot gf_jitter(tip_percent ~ condition, data = tip_exp, width = .1, color = ~gender) %>% gf_facet_grid(. ~ gender) # fit and save the interaction model interaction_model <- lm(tip_percent ~ condition * gender, data = tip_exp) # add code to put the interaction model on this plot gf_jitter(tip_percent ~ condition, data = tip_exp, width = .1, color = ~gender) %>% gf_facet_grid(. ~ gender) %>% gf_model(interaction_model) ex() %>% check_or( check_function(., "gf_model") %>% check_arg("model") %>% check_equal(), override_solution(., "gf_jitter(tip_percent ~ condition, data = tip_exp, width = .1, color = ~gender) %>% gf_facet_grid(. ~ gender) %>% gf_model(lm(tip_percent ~ gender * condition, data = tip_exp))") %>% check_function("gf_model") %>% check_arg("model") %>% check_equal() )
CK Code: D4_Code_Interactions_02
require(coursekata) # nothing has been saved for you # the data frame is called tip_exp # nothing has been saved for you # the data frame is called tip_exp lm(tip_percent ~ condition * gender, data = tip_exp) # alternatively: lm(tip_percent ~ gender * condition, data = tip_exp) ex() %>% check_or( check_function(., "lm") %>% check_result() %>% check_equal(), override_solution(., "lm(tip_percent ~ gender * condition, data = tip_exp)") %>% check_function("lm") %>% check_result() %>% check_equal() )
CK Code: D4_Code_Predictions_01
require(coursekata) # no models have been created for you # generate the ANOVA table for the interaction model (remember to use verbose=FALSE) # no models have been created for you # generate the ANOVA table for the interaction model (remember to use verbose=FALSE) supernova(lm(tip_percent ~ condition * gender, data = tip_exp), verbose = FALSE) # alternatively: supernova(lm(tip_percent ~ gender * condition, data = tip_exp), verbose = FALSE) ex() %>% check_or( check_function(., "supernova") %>% check_result() %>% check_equal(), override_solution(., "supernova(lm(tip_percent ~ gender * condition, data = tip_exp), verbose = FALSE)") %>% check_function("supernova") %>% check_result() %>% check_equal() )
CK Code: D4_Code_Factorial_01

Responses