calibrate.lm evaluates models generated with poly()
calibrate() is only defined for linear regression models, however, the following code works
mod <- lm(measured ~ poly(actual,2),arsenic) calibrate(mod,3) estimate lower upper -0.0438647 -0.0746398 -0.0131698
The problem is that both checks in calibrate.R fail:
xname <- all.vars(stats::formula(object)[[3L]]) if (length(xname) != 1L) { stop("Only one independent variable allowed.") }
passes, because poly(actual,2) only returns "actual".
mf <- stats::model.frame(object) if (ncol(mf) != 2) { stop("calibrate only works for the simple linear regression model.") }
passes, because poly() returns a matrix which model.frame returns as matrix column, so ncol(mf) == 2.
additional or modified checks required. To me its also unclear why xname is extracted from formula(object) instead of simply object$terms and why x and y are not simply taken from the model frame (since it must be linear).