# What is the consequence from building polynomial regression with multiple ind. variables?

I'm exploring polynomial regression. I understand how to execute it for cases with one independent variable.

What about cases with multiple independent variables?

I'm working with the boston housing data. here is my polynomial regression code

#choose the polynomial degree with cross validation
#initialize the dataframe
cv.errors <- data.frame(degree=seq(1,5,1),
error= rep(NA, 5))

#find the 10-fold error for 1-5 degree polynomials
for (i in 1:5) {
glm.fit <- glm(medv~poly(age, i), data=Boston_Ready)
cv.errors$$error[i] <- cv.glm(Boston_Ready, glm.fit, K=10)$$delta[1]
}
kable(cv.errors)


Say, I wanted to do polynomial regression with multiple independent variables. Could I just find the right polynomial for each predictor individually and then construct a model with each of the polynomials put together?

Like this

fit <- lm(medv~poly(age, 4)+poly(indus,2)+poly(nox,2)+chas, data=Boston)

• You should not use polynomials without a good reason. It can very quickly lead to overfitting. If you do in fact have a non-linear relationship then use domain knowledge if possible to determine the degree, otherwise something like splines would be a better choice. – user2974951 Jan 16 at 8:35
• And even if you have a good reason you should not fit a multiple individual regression and fit them together. – peteR Jan 16 at 11:26
• does this mean I can only fit a polynomial regression with one predictor? – Sebastian Jan 16 at 19:54