Note that we could have directly computed the probabilities by selecting
the type="response"
option in the predict()
function.
preds <- predict(fit, newdata = list(age = age.grid), type = "response", se = TRUE)
However, the corresponding confidence intervals would not have been sensible because we would end up with negative probabilities!
medv
as dependent variable and a degree-3 polynomial of dis
as independent variable).
Store the result in fit
.medv
for a series of values of dis
, ranging from 1 mile to 12 miles, in steps of 0.1 mile.
This time, use the type="response"
option.
Store the results in the variable preds
.se.bands
. Make use of the cbind
function in order to column bind the two vectors.dis
dis
dis
Assume that: