Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calibrate.lm evaluates models generated with poly() #48

Open
Taxecron opened this issue Dec 27, 2022 · 0 comments
Open

calibrate.lm evaluates models generated with poly() #48

Taxecron opened this issue Dec 27, 2022 · 0 comments

Comments

@Taxecron
Copy link

Taxecron commented Dec 27, 2022

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant