全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3612 5
2012-03-30
悬赏 24 个论坛币 已解决
比如我有beef这个data,里面cattle和income两个变量,income是response,simple linear model,那么如何找出outliers呢?我用identify(cattle,income)没反应啊!

最佳答案

epoh 查看完整内容

S-plus,可能是因为破解没完全 identify的确失去点选outlier的功能 不过无妨可以在R实现 ####### beef=read.table("beef.txt",header=T) fit=lm(cattle~income,data=beef) plot(fit$residuals,fit$fitted.values) identify(fit$residuals,fit$fitted.values) #[1] 96 98 2楼kk22boy兄建议的package "outlier", 结果如下: library(outlier) outlier(cbind(fit$residuals,fit$fitted.values)) #[1] 55301.60 25811.8 ...
二维码

扫码加我 拉你入群

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

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

全部回复
2012-3-30 21:17:04
hrbatanu 发表于 2012-4-1 12:38
Another way to lessen the in
uence of individual points is to simply remove them. From
the origi ...
S-plus,可能是因为破解没完全
identify的确失去点选outlier的功能
不过无妨可以在R实现
#######
beef=read.table("beef.txt",header=T)
fit=lm(cattle~income,data=beef)
plot(fit$residuals,fit$fitted.values)
identify(fit$residuals,fit$fitted.values)
#[1] 96 98

2楼kk22boy兄建议的package "outlier",
结果如下:
library(outlier)
outlier(cbind(fit$residuals,fit$fitted.values))
#[1] 55301.60 25811.86
二维码

扫码加我 拉你入群

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

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

2012-3-31 23:08:40
eg1:
ols <- lm(crime ~ poverty + single, data = cdata)
library(MASS)
d1 <- cooks.distance(ols)
r <- stdres(ols)
具体参考http://www.ats.ucla.edu/stat/R/dae/rreg.htm
eg2:有具体的package::outliers
二维码

扫码加我 拉你入群

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

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

2012-3-31 23:09:25
或者你把数据发出来,我们看看
二维码

扫码加我 拉你入群

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

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

2012-4-1 12:35:01
> beef
   cattle   income
1  14832  3630456
2   1911   193634
3   1531   214145
4   1965   287803
5  18141   999671
6    141    16468
7   6692   822145
8    168    16021
9   5086   220287
10    290    49286
11    325    44021
12    134    70068
13    665    77884
14    595   126310
15    592   118359
16   3277   349431
17    259    34122
18    208    23981
19    239    26426
20    593   119722
21   1121   606184
22  24250   588194
23    351   103689
   cattle   income
24   1442   210247
25   1610   282934
26    181    41081
27    173    33313
28    249    12055
29   2686   213398
30    342    20503
31    429   101683
32    281    78563
33    339    26799
34    105    28840
35   1431   252233
36   3389   153112
37    514    89658
38   1175   132956
39    459    55734
40    538    10893
41   3007   465944
42   3277   468923
43  18013  1315913
44   2125   494385
45   8401   134436
46   5883   427188
   cattle   income
47   2646   410967
48   1223   118428
49    188    43745
50    103    26435
51    185    19820
52   2964   309145
53    250   209316
54  11004   617851
55   4246   404831
56   4575    79056
57    221    38301
58   1375   223394
59    112    66684
60    451    92970
61    230   103659
62   1667   214857
63   2039   263240
64   6942   320144
65    847   232934
66   2054   875489
67   1016    69250
68    181    80360
69   4232   732872
   cattle   income
70    565    51043
71   5977   288565
72    443    22575
73   1603   246304
74     92    31451
75    884   170136
76    437    82097
77   2109   343639
78    169    44743
79    349    33758
80    377   276492
81    793   135255
82    225    35029
83    458    63162
84   1039   165257
85    500    93410
86    559   116247
87  14500   228156
88   1154   309389
89    432    54298
90  11511   661368
91  14726   407532
92    256    68937
    cattle   income
93   1889   271146
94   4316   361801
95    336    27863
96  60015  2818570
97    320    22126
98  17994 36304932
99    684    81046
100    613    70692
101   2246   146873
102   2755   425437
103   1176   284266
104    419    36882
105    310    91399
106   1087   167938
107   4314   228967
108   6714   287163
109    126    19995
110    993    71118
111   2565   190808
112    173    16772
113    826   147935
114    340    51622
115   3003   353893
    cattle   income
116  11139   854782
117    881   119712
118  20155   104005
119    749    69877
120    168   416050
121   1025   188614
122   1850   101754
123   4555   226507
124   2617   187831
125    154    17413
126   5243   670722
127    263    32119
128   4468  1577290
129    201    13176
130    264   148394
131   2630   737972
132    494    59190
133   1184   156488
134   3060   753634
135    477    30978
136   2080   287207
137   4924   310988
138   5724   323681
    cattle   income
139   2755   238682
140   2423   168930
141    494   116168
142    224    99332
143   4977   467529
144   1446   267117
145     68    30711
146   1550   130827
147    187    87847
148    846   227378
149   4207   263096
150  21306  1286532
151   7826   259643
152   1329   124160
153   4194   511397
154    243   175833
155   5320  1039415
156    317    31363
157  11070   773309
158   5386   428145
159   6820   702676
>
二维码

扫码加我 拉你入群

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

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

2012-4-1 12:38:03
kk22boy 发表于 2012-3-31 23:09
或者你把数据发出来,我们看看
Another way to lessen the in
uence of individual points is to simply remove them. From
the original, untransformed data, which two points seem the most likely candidates for
removal? Fit a regression to the original dataset with these two points removed. Again,
plot the data and superimpose the regression line. Also, create a residual plot and a
leverage barplot and compare it to the other two sets of plots you have already drawn.
我今天用identify手动把两个outliers标出来了,第96和98,但是不知道对不对啊,什么方法更精确呢
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群