R语言中 fitted()和predict()的区别

时间:2014-05-11 00:37:44   收藏:0   阅读:652

fitted是拟合值,predict是预测值。模型是基于给定样本的值建立的,在这些给定样本上做预测就是拟合。在新样本上做预测就是预测。

你可以找一组数据试试,结果如何。
fit<-lm(weight~height,data=women)
fitted(fit)
predict(fit,newdata=data.frame(height=90))##将90代入看结果如何
这是R in action中的例子

R语言中 fitted()和predict()的区别,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!