admin管理员组文章数量:1279116
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")
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")
Share
Improve this question
edited Feb 24 at 5:19
Jan
9,3386 gold badges20 silver badges33 bronze badges
asked Feb 24 at 4:34
stella1897stella1897
574 bronze badges
1
|
1 Answer
Reset to default 1I 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)
本文标签: rSingular Matrix 39a39 in solveStack Overflow
版权声明:本文标题:r - Singular Matrix 'a' in solve - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741294240a2370723.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
*
with+
– Edward Commented Feb 24 at 5:30