1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> ### tests methods argument of lmrob.control
>
> library(robustbase)
>
> data(stackloss)
>
> ## S
> set.seed(0)
> summary(m0 <- lmrob(stack.loss ~ ., data = stackloss, method = "S"))
Length Class Mode
coefficients 4 -none- numeric
scale 1 -none- numeric
k.iter 1 -none- numeric
converged 1 -none- logical
fitted.values 21 -none- numeric
residuals 21 -none- numeric
weights 21 -none- numeric
control 19 -none- list
qr 4 qr list
rank 1 -none- numeric
cov 16 -none- numeric
df.residual 1 -none- numeric
degree.freedom 1 -none- numeric
xlevels 0 -none- list
call 4 -none- call
terms 3 terms call
model 4 data.frame list
x 84 -none- numeric
Warning message:
In lf.cov(init, x) :
:.vcov.w: ignoring cov.resid == final since est != final
> set.seed(0)
> m0a <- lmrob.S(m0$x, stack.loss, lmrob.control())
>
> all.equal(m0[c('coefficients', 'scale', 'weights')],
+ m0a[c('coefficients', 'scale', 'weights')])
[1] TRUE
>
> ## MM
> set.seed(0)
> summary(m1 <- lmrob(stack.loss ~ ., data = stackloss, method = "MM"))
Call:
lmrob(formula = stack.loss ~ ., data = stackloss, method = "MM")
Weighted Residuals:
Min 1Q Median 3Q Max
-10.50974 -1.43819 -0.09134 1.02503 7.23113
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -41.52462 5.29780 -7.838 4.82e-07 ***
Air.Flow 0.93885 0.11743 7.995 3.68e-07 ***
Water.Temp 0.57955 0.26296 2.204 0.0416 *
Acid.Conc. -0.11292 0.06989 -1.616 0.1246
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Robust residual standard error: 1.912
Convergence in 17 IRWLS iterations
Robustness weights:
observation 21 is an outlier with |weight| = 0 ( < 0.0048);
2 weights are ~= 1. The remaining 18 ones are summarized as
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1215 0.8757 0.9428 0.8721 0.9797 0.9978
Algorithmic parameters:
tuning.chi bb tuning.psi refine.tol rel.tol
1.5476400 0.5000000 4.6850610 0.0000001 0.0000001
nResample max.it groups n.group best.r.s k.fast.s k.max
500 50 5 400 2 1 200
trace.lev compute.rd numpoints
0 0 10
psi method cov
"bisquare" "MM" ".vcov.avar1"
seed : int(0)
>
> set.seed(0)
> m2 <- update(m1, method = "SM")
>
> all.equal(m1[c('coefficients', 'scale', 'cov')],
+ m2[c('coefficients', 'scale', 'cov')])
[1] TRUE
>
> set.seed(0)
> m3 <- update(m0, method = "SM", cov = '.vcov.w')
>
> ## SMD
> set.seed(0)
> summary(m4 <- lmrob(stack.loss ~ ., data = stackloss, method = "SMD", psi = 'bisquare'))
Call:
lmrob(formula = stack.loss ~ ., data = stackloss, method = "SMD",
psi = "bisquare")
Weighted Residuals:
Min 1Q Median 3Q Max
-10.50974 -1.43819 -0.09134 1.02503 7.23113
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -41.5246 8.8552 -4.689 0.000211 ***
Air.Flow 0.9388 0.1162 8.078 3.2e-07 ***
Water.Temp 0.5796 0.3164 1.831 0.084610 .
Acid.Conc. -0.1129 0.1163 -0.971 0.345380
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Robust residual standard error: 2.651
Convergence in 17 IRWLS iterations
Robustness weights:
observation 21 is an outlier with |weight| = 0 ( < 0.0048);
2 weights are ~= 1. The remaining 18 ones are summarized as
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1215 0.8757 0.9428 0.8721 0.9797 0.9978
Algorithmic parameters:
tuning.chi bb tuning.psi refine.tol rel.tol
1.5476400 0.5000000 4.6850610 0.0000001 0.0000001
nResample max.it groups n.group best.r.s k.fast.s k.max
500 50 5 400 2 1 200
trace.lev compute.rd numpoints
0 0 10
psi method cov
"bisquare" "SMD" ".vcov.w"
seed : int(0)
> summary(m4a <- lmrob..D..fit(m3))
Call:
lmrob(formula = stack.loss ~ ., data = stackloss, method = "SMD",
cov = ".vcov.w")
Weighted Residuals:
Min 1Q Median 3Q Max
-10.50974 -1.43819 -0.09134 1.02503 7.23113
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -41.5246 8.8552 -4.689 0.000211 ***
Air.Flow 0.9388 0.1162 8.078 3.2e-07 ***
Water.Temp 0.5796 0.3164 1.831 0.084610 .
Acid.Conc. -0.1129 0.1163 -0.971 0.345380
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Robust residual standard error: 2.651
Convergence in 17 IRWLS iterations
Robustness weights:
observation 21 is an outlier with |weight| = 0 ( < 0.0048);
2 weights are ~= 1. The remaining 18 ones are summarized as
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1215 0.8757 0.9428 0.8721 0.9797 0.9978
Algorithmic parameters:
tuning.chi bb tuning.psi refine.tol rel.tol
1.5476400 0.5000000 4.6850610 0.0000001 0.0000001
nResample max.it groups n.group best.r.s k.fast.s k.max
500 50 5 400 2 1 200
trace.lev compute.rd numpoints
0 0 10
psi method cov
"bisquare" "SMD" ".vcov.w"
seed : int(0)
>
> ## rearrange m4a and update call
> m4a <- m4a[names(m4)]
> class(m4a) <- class(m4)
> m4a$call <- m4$call
>
> all.equal(m4, m4a)
[1] TRUE
>
> ## SMDM
> set.seed(0)
> summary(m5 <- lmrob(stack.loss ~ ., data = stackloss, method = "SMDM", psi = 'bisquare'))
Call:
lmrob(formula = stack.loss ~ ., data = stackloss, method = "SMDM",
psi = "bisquare")
Weighted Residuals:
Min 1Q Median 3Q Max
-9.6746 -1.7721 0.1346 1.2041 6.6080
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -41.9398 9.6482 -4.347 0.000438 ***
Air.Flow 0.8747 0.1215 7.198 1.49e-06 ***
Water.Temp 0.8099 0.3320 2.439 0.025977 *
Acid.Conc. -0.1188 0.1268 -0.937 0.361693
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Robust residual standard error: 2.651
Convergence in 17 IRWLS iterations
Robustness weights:
2 weights are ~= 1. The remaining 19 ones are summarized as
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1546 0.9139 0.9597 0.8874 0.9866 0.9966
Algorithmic parameters:
tuning.chi bb tuning.psi refine.tol rel.tol
1.5476400 0.5000000 4.6850610 0.0000001 0.0000001
nResample max.it groups n.group best.r.s k.fast.s k.max
500 50 5 400 2 1 200
trace.lev compute.rd numpoints
0 0 10
psi method cov
"bisquare" "SMDM" ".vcov.w"
seed : int(0)
> summary(m5a <- lmrob..M..fit(obj=m4))
Call:
lmrob(formula = stack.loss ~ ., data = stackloss, method = "SMDM",
psi = "bisquare")
Weighted Residuals:
Min 1Q Median 3Q Max
-9.6746 -1.7721 0.1346 1.2041 6.6080
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -41.9398 9.6482 -4.347 0.000438 ***
Air.Flow 0.8747 0.1215 7.198 1.49e-06 ***
Water.Temp 0.8099 0.3320 2.439 0.025977 *
Acid.Conc. -0.1188 0.1268 -0.937 0.361693
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Robust residual standard error: 2.651
Convergence in 17 IRWLS iterations
Robustness weights:
2 weights are ~= 1. The remaining 19 ones are summarized as
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1546 0.9139 0.9597 0.8874 0.9866 0.9966
Algorithmic parameters:
tuning.chi bb tuning.psi refine.tol rel.tol
1.5476400 0.5000000 4.6850610 0.0000001 0.0000001
nResample max.it groups n.group best.r.s k.fast.s k.max
500 50 5 400 2 1 200
trace.lev compute.rd numpoints
0 0 10
psi method cov
"bisquare" "SMDM" ".vcov.w"
seed : int(0)
>
> ## rearrange m5a
> m5a <- m5a[names(m5)]
> class(m5a) <- class(m5)
>
> all.equal(m5, m5a)
[1] TRUE
>
|