When I try to plot my mrl_model I get an error message in xy coordinates. I do not know enough about R to troubleshoot this issue. Can someone help me to resolve this error?
set.seed(1234)
ind <- sample(2, nrow(New_imports), replace = TRUE, prob = c(0.7, 0.3))
train.data <- New_imports[ind == 1, ]
test.data <- New_imports[ind == 2, ]
myFormula<-Price~.
mlr_model<-lm(myFormula, data=train.data)
print(mlr_model)
Call:
lm(formula = myFormula, data = train.data)
Coefficients:
(Intercept) symboling normalized_losses aspirationturbo num_doorstwo
-44140.550 -206.852 8.956 1538.373 -83.248
body_stylehardtop body_stylehatchback body_stylesedan body_stylewagon drive_wheelsfwd
-12119.455 -11201.288 -10659.429 -10655.282 -1466.030
drive_wheelsrwd engine_locationrear wheel_base length width
702.577 2415.164 95.239 -89.271 792.837
height curb_weight engine_size compression_ratio peak_rpm
-13.931 3.403 45.880 91.632 1.333
city_mpg highway_mpg
-221.142 155.776
pred <-predict(mlr_model, New_imports=test.data)
plot(test.data$Price, pred, xlab = "Observed", ylab = "Prediction")
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ