Reputation: 57
I am trying to use predict function in RStudio on some new data. However I keep getting an error, "Error in qr.solve(qr.R(qrX)[p1, p1]) : singular matrix 'a' in solve". Where is my mistake? Should I have a simpler model?
lm.price.new <- lm(price ~ bedrooms * bathrooms * sqft_living * sqft_lot * floors *
waterfront * view * condition * grade, data = kc_house_data)
summary(lm.price.new)
new.house <- data.frame(bedrooms = 4, bathrooms = 2, sqft_living = 2560, sqft_lot = 7650,
floors = 1.5, waterfront = 1, view = 3, condition = 5,
grade = 10)
predict(lm.price.new, newdata = new.house, interval = "predict")
Upvotes: 0
Views: 45
Reputation: 57
I changed the model to not include cross effects as that was what was causing the singularities. Here is what I changed.
lm.price.new1 <- lm(price ~ bedrooms + bathrooms + sqft_living + sqft_lot + floors +
waterfront + view + condition + grade, data = kc_house_data)
Upvotes: 1