Vorhersagen mit Interaktionen manuell berechnen
Um zu verstehen, wie predict() funktioniert, berechnen wir die Vorhersagen noch einmal manuell. Bei diesem Modell gibt es drei separate Geraden, und in jeder ist die Vorhersage ein Achsenabschnitt plus eine Steigung mal dem numerischen erklärenden Wert. Die Herausforderung ist, in jedem Fall den richtigen Achsenabschnitt und die richtige Steigung zu wählen.
mdl_price_vs_both_inter und explanatory_data sind verfügbar; dplyr und tidyr sind verfügbar.
Diese Übung ist Teil des Kurses
Fortgeschrittene Regression in R
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Get the coefficients from mdl_price_vs_both_inter
coeffs <- ___
# Get the intercept for 0 to 15 year age group
intercept_0_15 <- ___
# Get the intercept for 15 to 30 year age group
intercept_15_30 <- ___
# Get the intercept for 30 to 45 year age group
intercept_30_45 <- ___
# Get the slope for 0 to 15 year age group
slope_0_15 <- ___
# Get the slope for 15 to 30 year age group
slope_15_30 <- ___
# Get the slope for 30 to 45 year age group
slope_30_45 <- ___