I have a explanatory variable that is centered using scale() that is used to predict a response variable:
d <- data.frame(
x=runif(100),
Old question, but why wouldn't you just do this:
plot(d$x, predict(m1, d))
As an easier way than manually using the attributes from the scaled object, DMwR has a function for this: unscale. It works like this:
d <- data.frame(
x=runif(100)
)
d$y <- 17 + d$x * 12
s.x <- scale(d$x)
m1 <- lm(d$y~s.x)
library(DMwR)
unsc.x <- unscale(d$x, s.x)
plot(unsc.x, predict(m1, d))
Importantly, the second argument of unscale needs to have something with the attributes of 'scaled:scale' and 'scaled:center'