Home runs and launch variables
\[ \log(\frac{\text{Pr}(HR)}{1-\text{Pr}(HR)}) = s(LA, LS) \] - Logistic GAM regression of probability of a Home Run vs:
LA : Launch angle
LS : Launch speed
s
is used in GAM to indicate a smooth function of the two measurements.
library(mgcv)
fit_23 <- gam(
HR ~ s(launch_angle, launch_speed),
family = binomial,
data = sc_2023
)
We can get predictions from the model:
fit_23 |>
predict(
newdata = data.frame(
launch_speed = 105,
launch_angle = 25
),
type = "response"
)
## 1
## 0.773