prediction icon indicating copy to clipboard operation
prediction copied to clipboard

Hard coded variable name x should be avoided

Open mronkko opened this issue 5 years ago • 1 comments
trafficstars

Please specify whether your issue is about:

  • [x ] a possible bug
  • [ ] a question about package functionality
  • [ ] a suggested code or documentation change, improvement to the code, or feature request

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

mronkko avatar May 28 '20 10:05 mronkko

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

leeper avatar Jun 20 '20 11:06 leeper