@fornanthu wrote:
Hi Guys,
Need your guidance as i would need clarification for below 3,
Input : data set having 26 features out of which i need to perform lm on price column.
data_raw <- read.csv(“file”)
lot <- sample(205,42)
data_train <- data_raw[lot.]
data_test <- data_raw[-lot,]
when i issue lm(price~.,data_train) i am getting an error as
“contrast can apply for factor variable having 2 or more level” .
However if i issue
lm(formula = price ~ symboling + normalized.losses + make + fuel.type +
aspiration + num.of.doors + body.style + drive.wheels + engine.location +
wheel.base + length + width + height + curb.weight + engine.type +
num.of.cylinders + engine.size + fuel.system + bore + stroke +
compression.ratio + horsepower + peak.rpm + city.mpg + highway.mpg,
data = data_raw)
no error appearing.when i issue
lm(formula = price ~ symboling + normalized.losses + make + fuel.type +
aspiration + num.of.doors + body.style + drive.wheels + engine.location +
wheel.base + length + width + height + curb.weight + engine.type +
num.of.cylinders + engine.size + fuel.system + bore + stroke +
compression.ratio + horsepower + peak.rpm + city.mpg + highway.mpg,
data = data_raw)
few coefficients are coming as NA. but i have searched for unique values of those NA coefficients but i have more than 5 rows having that coefficients.In summary(model) shows
engine.typeohc 8.250e+02 1.299e+03 0.635 0.526547
engine.typeohcf NA NA NA NA
engine.typeohcv -1.484e+03 1.424e+03 -1.041 0.299548
engine.typerotor 4.636e+03 4.783e+03 0.969 0.334262
num.of.cylindersfive -7.068e+03 2.588e+03 -2.731 0.007167 **
num.of.cylindersfour -4.833e+03 3.114e+03 -1.552 0.123069
num.of.cylinderssix -3.492e+03 2.789e+03 -1.252 0.212684
num.of.cylinderstwelve 8.230e+02 6.116e+03 0.135 0.893157
num.of.cylinderstwo NA NA NA NA
engine.size 1.011e+02 2.577e+01 3.921 0.000140 ***
fuel.system2bbl 3.375e+03 1.688e+03 2.000 0.047552 *
fuel.system4bbl -1.062e+03 2.779e+03 -0.382 0.702981
fuel.systemidi NA NA NA NAtwo is one of values in “num.of.cylinder”… i am confused as summary suggested that cylinder two is not relevant for the model… In this case, how to remove or how do i proceed.
looking forward your support here.
Posts: 1
Participants: 1