stat-learning icon indicating copy to clipboard operation
stat-learning copied to clipboard

Ch3 Ex9c

Open actuarialcat opened this issue 7 years ago • 0 comments

The question requires the use of multiple linear regression. The predictor "origin" is stored as a num, but it is a qualitative data. Shouldn't it be change to factor using the following code before doing the regression?

origin_fac = factor(Auto$origin, levels = c("American","European","Japanese"))
new_data = subset(Auto, select = -c(name,origin))
new_data = new_data.frame(new_data, origin_fac)
lm.fix =  lm(mpg~. ,data= new_data)

actuarialcat avatar Sep 16 '18 13:09 actuarialcat