Relative Content

Tag Archive for r

Prediction with a factor in R

I am confused with doing multiple linear regression with a factor in R. A is the binary variable, coded as 1 and -1 as a factor in lm. So, when making a prediction, how do we treat A=-1 with the coefficient, which is for A=1? I tried to figure out the fitted values for the first five obs, but it seems predict and my calculation don’t result the same. What mistake did I make here?