I have a multiple regression model. I want to add the fitted values and residuals to the original data.frame
as two new columns. How can I achieve that? My model in R is like this:
BD_lm <- lm(y ~ x1+x2+x3+x4+x5+x6, data=BD)
summary(BD)
I also got the fitted value
BD_fit<-fitted(BD_lm)
But I want to add this BD_fit
values as a column to my original data BD
. I don't know how. When I tried to call BD_fit
, it just gave me a lot of numbers. I am running a large dataset, so it is hard to list all of them here.