leeper / prediction

Tidy, Type-Safe 'prediction()' Methods
https://cran.r-project.org/package=prediction
Other
89 stars 14 forks source link

Hard coded variable name x should be avoided #46

Open mronkko opened 4 years ago

mronkko commented 4 years ago

Please specify whether your issue is about:

The summary method has a hard coded variable name x. This is problematic: x is quite commonly used as the name for a predictor variable when teaching regression. If we have x as a predictor, the summary method incorrectly selects the predictors as the predicted value and vice versa.

Put your code here:

## load package
library("prediction")

## code goes here

set.seed(12345)
N <- 200

x <- rnorm(N)
y <- x+rnorm(N)

m1 <- lm(y ~ x)

p1 <- prediction(m1, at=list(x=-3:3))
summary(p1)

## session info for your system
sessionInfo()
leeper commented 4 years ago

If you're able, can you send a pull request that fixes this? Thanks!