楼主: 19930413xxy
55795 11

[问答] R语言中 fitted()和predict()的区别 [推广有奖]

  • 0关注
  • 0粉丝

等待验证会员

已卖:5份资源

高中生

7%

还不是VIP/贵宾

-

威望
0
论坛币
13 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
53 点
帖子
4
精华
0
在线时间
35 小时
注册时间
2014-2-7
最后登录
2017-6-30

楼主
19930413xxy 发表于 2014-3-16 12:35:19 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
R对数据做线性拟合后,命令fitted(lm.sol)和predict(lm.sol)有什么区别?分别是怎么计算的
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:predict fitted Pred edi fit

回帖推荐

lww1993 发表于3楼  查看完整内容

你可以找一组数据试试,结果如何。 fit

lww1993 发表于2楼  查看完整内容

假设你是做的模型是y~x,给的值是(x1,x2,...,xn),(y1,y2,...,yn) fitted()的结果是你得到相应的模型后,(x1,x2,...,xn)相应的值,也就是(y1,y2,...,yn)的估计值 predict()中你可以用(x1,x2,...,xn)的值,也可以用新的值,看下你的预测值为多少。

hongweigg 发表于7楼  查看完整内容

predict()中未见有type参数。 --------------------------------------------------------------------------------------------------- predict {stats} R Documentation Model Predictions Description predict is a generic function for predictions from the results of various model fitting functions. The function invokes particular methods which depend on the class of the first argument. Usage p ...

本帖被以下文库推荐

沙发
lww1993 发表于 2014-3-16 22:25:54
假设你是做的模型是y~x,给的值是(x1,x2,...,xn),(y1,y2,...,yn)
fitted()的结果是你得到相应的模型后,(x1,x2,...,xn)相应的值,也就是(y1,y2,...,yn)的估计值
predict()中你可以用(x1,x2,...,xn)的值,也可以用新的值,看下你的预测值为多少。
已有 3 人评分经验 论坛币 学术水平 收起 理由
yin479816697 + 1 精彩帖子
我的素质低 + 20 精彩帖子
ltx5151 + 20 热心帮助其他会员

总评分: 经验 + 20  论坛币 + 20  学术水平 + 1   查看全部评分

藤椅
lww1993 发表于 2014-3-16 22:27:34
你可以找一组数据试试,结果如何。
fit<-lm(weight~height,data=women)
fitted(fit)
predict(fit,newdata=data.frame(height=90))##将90代入看结果如何
这是R in action中的例子
已有 1 人评分论坛币 收起 理由
admin_kefu + 20 热心帮助其他会员

总评分: 论坛币 + 20   查看全部评分

板凳
ltx5151 发表于 2014-3-17 11:10:18
fitted是拟合值,predict是预测值。你的模型是基于给定样本的值建立的,在这些给定样本上做预测就是拟合。在新样本上做预测就是预测。lz可以仔细查一下相关概念。

报纸
hbwzhsh 发表于 2014-4-4 23:33:30
原来如此
不懂就要问

地板
你们好啊 学生认证  发表于 2015-8-6 17:49:04
请问predict(type=‘prob’和type=‘response’)输出的结果是什么呢?我怎么跑出来结果都是一样的
求指导

7
hongweigg 发表于 2015-8-19 11:21:41
你们好啊 发表于 2015-8-6 17:49
请问predict(type=‘prob’和type=‘response’)输出的结果是什么呢?我怎么跑出来结果都是一样的
求指导 ...
predict()中未见有type参数。

---------------------------------------------------------------------------------------------------
predict {stats}        R Documentation
Model Predictions
Description

predict is a generic function for predictions from the results of various model fitting functions. The function invokes particular methods which depend on the class of the first argument.
Usage

predict (object, ...)

Arguments
object        

a model object for which prediction is desired.
...        

additional arguments affecting the predictions produced.
Details

Most prediction methods which are similar to those for linear models have an argument newdata specifying the first place to look for explanatory variables to be used for prediction. Some considerable attempts are made to match up the columns in newdata to those used for fitting, for example that they are of comparable types and that any factors have the same level set in the same order (or can be transformed to be so).

Time series prediction methods in package stats have an argument n.ahead specifying how many time steps ahead to predict.

Many methods have a logical argument se.fit saying if standard errors are to returned.
Value

The form of the value returned by predict depends on the class of its argument. See the documentation of the particular methods for details of what is produced by that method.
References

Chambers, J. M. and Hastie, T. J. (1992) Statistical Models in S. Wadsworth & Brooks/Cole.
已有 1 人评分论坛币 收起 理由
admin_kefu + 20 热心帮助其他会员

总评分: 论坛币 + 20   查看全部评分

8
zhurui1351 发表于 2015-9-25 09:37:11
参考?predict.lm中对type的说明

9
colisland 发表于 2018-4-4 21:09:58
了解了

10
weifeng9011 发表于 2018-4-27 06:58:55
学习一下

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 10:23