楼主: peijianshi
19375 7

怎么提取summary()中的残差值 [推广有奖]

  • 0关注
  • 16粉丝

已卖:352份资源

副教授

80%

还不是VIP/贵宾

-

威望
0
论坛币
638 个
通用积分
2.3662
学术水平
12 点
热心指数
12 点
信用等级
5 点
经验
15373 点
帖子
636
精华
0
在线时间
568 小时
注册时间
2010-3-11
最后登录
2022-9-8

楼主
peijianshi 发表于 2010-4-6 09:59:20 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
> summary(xian2)

Call:
lm(formula = r2 ~ T2)
Residuals:
       Min         1Q     Median         3Q        Max
-0.0680301 -0.0126145 -0.0006432  0.0127143  0.0615278
Coefficients:
              Estimate Std. Error t value Pr(>|t|)   
(Intercept) -0.2135051  0.0033632  -63.48   <2e-16 ***
T2           0.0201425  0.0001566  128.60   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01971 on 713 degrees of freedom
Multiple R-squared: 0.9587,     Adjusted R-squared: 0.9586
F-statistic: 1.654e+04 on 1 and 713 DF,  p-value: < 2.2e-16

现在要提取红字部分0.01971,怎么办好呢?
二维码

扫码加我 拉你入群

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

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

关键词:Summary Summa Mary Mar Sum 残差 Summary

已有 1 人评分学术水平 收起 理由
bella501907914 + 1 精彩帖子

总评分: 学术水平 + 1   查看全部评分

沙发
iid_garch 发表于 2010-4-6 10:34:36
model <- summary(xian2)
model$sigma

藤椅
治感冒 发表于 2010-4-6 23:22:16
resid(model) 或者model$resid都可以提取残差序列

板凳
bella501907914 发表于 2014-6-23 17:03:40
十分感谢,帮了我大忙了

报纸
galilee 在职认证  发表于 2014-6-24 18:32:03
是这样的,你可以用 names 或者 str 函数看到一个object内部的情况和typeof函数来看object的type。
这样你就看到残差在residuals里面,而这个summary是一个list,所以你就可以用 summary(mdl)$residuals
来得到残差。
  1. > names(summary(mdl))
  2. [1] "call"          "terms"         "residuals"     "coefficients"
  3. [5] "aliased"       "sigma"         "df"            "r.squared"   
  4. [9] "adj.r.squared" "fstatistic"    "cov.unscaled"
  5. >str(summary(mdl))
  6. List of 11
  7. $ call         : language lm(formula = y1 ~ x1)
  8. $ terms        :Classes 'terms', 'formula' length 3 y1 ~ x1
  9.   .. ..- attr(*, "variables")= language list(y1, x1)
  10.   .. ..- attr(*, "factors")= int [1:2, 1] 0 1
  11.   .. .. ..- attr(*, "dimnames")=List of 2
  12.   .. .. .. ..$ : chr [1:2] "y1" "x1"
  13.   .. .. .. ..$ : chr "x1"
  14.   .. ..- attr(*, "term.labels")= chr "x1"
  15.   .. ..- attr(*, "order")= int 1
  16.   .. ..- attr(*, "intercept")= int 1
  17.   .. ..- attr(*, "response")= int 1
  18.   .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
  19.   .. ..- attr(*, "predvars")= language list(y1, x1)
  20.   .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "numeric"
  21.   .. .. ..- attr(*, "names")= chr [1:2] "y1" "x1"
  22. $ residuals    : Named num [1:100] -1.452 -0.327 0.114 2.161 -1.562 ...
  23.   ..- attr(*, "names")= chr [1:100] "1" "2" "3" "4" ...
  24. $ coefficients : num [1:2, 1:4] -0.00504 4.89803 0.1043 0.10449 -0.04835 ...
  25.   ..- attr(*, "dimnames")=List of 2
  26.   .. ..$ : chr [1:2] "(Intercept)" "x1"
  27.   .. ..$ : chr [1:4] "Estimate" "Std. Error" "t value" "Pr(>|t|)"
  28. $ aliased      : Named logi [1:2] FALSE FALSE
  29.   ..- attr(*, "names")= chr [1:2] "(Intercept)" "x1"
  30. $ sigma        : num 1.04
  31. $ df           : int [1:3] 2 98 2
  32. $ r.squared    : num 0.957
  33. $ adj.r.squared: num 0.957
  34. $ fstatistic   : Named num [1:3] 2197 1 98
  35.   ..- attr(*, "names")= chr [1:3] "value" "numdf" "dendf"
  36. $ cov.unscaled : num [1:2, 1:2] 0.010081 0.000903 0.000903 0.010118
  37.   ..- attr(*, "dimnames")=List of 2
  38.   .. ..$ : chr [1:2] "(Intercept)" "x1"
  39.   .. ..$ : chr [1:2] "(Intercept)" "x1"
  40. - attr(*, "class")= chr "summary.lm"
  41. > typeof(summary(mdl))
  42. [1] "list"
复制代码


地板
lww1993 发表于 2015-3-18 10:11:59
向上面的各位学习了。class(), str(),可以告诉如何提出元素。

7
xucaifeng66 发表于 2015-3-19 15:40:38
galilee 发表于 2014-6-24 18:32
是这样的,你可以用 names 或者 str 函数看到一个object内部的情况和typeof函数来看object的type。
这样你 ...
很赞,现在我有一个问题,就是不知道怎么提取图片上的数据,就好比我可以根据数据画出图像但是无法根据图像提取出数据,请问各位有什么好办法??

8
xucaifeng66 发表于 2015-3-19 15:40:41
galilee 发表于 2014-6-24 18:32
是这样的,你可以用 names 或者 str 函数看到一个object内部的情况和typeof函数来看object的type。
这样你 ...
很赞,现在我有一个问题,就是不知道怎么提取图片上的数据,就好比我可以根据数据画出图像但是无法根据图像提取出数据,请问各位有什么好办法??

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

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