kendallbraun
kendallbraun

Reputation: 11

linear regression in R

I'm trying to predict automobile prices based on a bunch of independent variables using linear regression. The only attributes in my data set that are chr is fuel and color, the rest are either num or int. I omitted fuel because it only has one level.
here is my code:

# Loading Data

car_data = read.csv("Car_Data (1).csv",header =TRUE)

car_data$Fuel <-NULL
car_data$Colour<- as.factor(car_data$Colour)
str(car_data)

set.seed(123)
indx <- sample(2, nrow(car_data), replace = T, prob = c(0.8, 0.2))
train <- car_data[indx == 1, ]
test <- car_data[indx == 2, ]

lmModel <- lm(Price ~ ., data = train)
summary(lmModel)

When I run the summary(lmModel), it shows all NA's for the Error, tvalue, and Pr(>|t|).

Can someone help...

Upvotes: 1

Views: 69

Answers (1)

Eric
Eric

Reputation: 166

It's possible that your dataset has too few observations in it and you are trying to fit too many features. It would be helpful for reproducibility if you could supply your dataset (or a minimal working example of a similar dataset). Perhaps you could also try running a simpler regression specification to see if that might tease out some errors.

lmModelSimple <- lm(Price ~ Colour, data = train)
summary(lmModelSimple)

Upvotes: 1

Related Questions