hello,

I am trying to use predict.lm to make point forecasts based on a model with
continuous and categorical independent variables
I have no problems fitting the model using lm, but when I try to use predict
to make point predictions. it reverts back to the original dataframe and
gives me the point predictions for the fitted data rather than for the new
data, I imagine that I am missing something simple but for whatever reason I
can't figure out why it does not like the new data and is reverting to the
fitted data. The following code illustrates the problem I am running in to.
Any help would be appreciated.

f1 <- rep(c("a","b","c","d"),25)
f2 <- sample(rep(c("e","f","g","h"),250),100)
x <- rnorm(100,100)
y <- rnorm(100,150)

mdl <- lm(y~x+f1+f2)

f12 <-rep(c("a","b","c","d"),5)
f22 <- sample(rep(c("e","f","g","h"),250),20)
x2 <- rnorm(20,100)

new <- data.frame(cbind(f12[1],f22[1],x2[1]))


predict(mdl,new)


best,

Spencer

	[[alternative HTML version deleted]]

