File: tlts.Rout.save

package info (click to toggle)
robustbase 0.99-6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,584 kB
  • sloc: fortran: 3,245; ansic: 3,243; sh: 15; makefile: 2
file content (544 lines) | stat: -rw-r--r-- 14,889 bytes parent folder | download | duplicates (6)
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544

R Under development (unstable) (2017-09-26 r73351) -- "Unsuffered Consequences"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

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.

> library(robustbase)
> ## library(MASS)## MASS::lqs
> 
> source(system.file("xtraR/test_LTS.R", package = "robustbase"))
> ##          ../inst/test_LTS.R
> 
> y20 <- c(2:4, 8, 12, 22, 28, 29, 33, 34, 38, 40, 41, 47:48, 50:51, 54, 56, 59)
> 
> test_location <- function() {
+     ## Improve: print less, and test equality explicitly
+     Y <- y20
+     print(ltsReg(y=Y))
+     print(ltsReg(y=Y, intercept=TRUE))
+     print(ltsReg(y=Y, intercept=FALSE))
+     print(ltsReg(y=Y, alpha=1))
+     print(ltsReg(Y ~ 1))
+     print(ltsReg(Y ~ 0))# = Y ~ 1 - 1 :  empty model (no coefficients)
+     print(ltsReg(Y ~ 1, alpha=1))
+ }
> 
> test_rsquared <- function() {
+     x1 <- y20
+     y1 <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 3.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5)
+     ll1 <- ltsReg(x1,y1, alpha = 0.8)
+     ## print() ing is platform-dependent, since only ~= 0
+     stopifnot(all.equal(unname(coef(ll1)), c(1,0), tolerance=1e-12),
+               ll1$scale < 1e-14)
+     print(ltsReg(y1,x1, alpha = 0.8))
+     print(ltsReg(y1,x1, alpha = 0.8, intercept = FALSE))
+ }
> 
> options(digits = 5)
> set.seed(101) # <<-- sub-sampling algorithm now based on R's RNG and seed
> 
> doLTSdata()

Call:  doLTSdata() 
========================================================
Data Set               n   p  Half      obj    Time [ms]
========================================================
               heart  12   2   8     0.065810 
Best subsample: 
[1]  1  2  4  5  6  7 11 12
Outliers:  4 
[1]  3  8  9 10
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept     height     weight  
   63.353     -1.227      0.688  

Scale estimate 1.52 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
     1      2      3      4      5      6      7      8      9     10     11 
-1.393  0.169  0.000  0.443 -0.341  0.165 -0.115  0.000  0.000  0.000  0.666 
    12 
 0.404 

Coefficients:
          Estimate Std. Error t value Pr(>|t|)    
Intercept  63.3528     4.0227   15.75  1.9e-05 ***
height     -1.2265     0.1403   -8.74  0.00032 ***
weight      0.6884     0.0528   13.04  4.7e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.765 on 5 degrees of freedom
Multiple R-Squared: 0.991,	Adjusted R-squared: 0.988 
F-statistic:  286 on 2 and 5 DF,  p-value: 6.99e-06 

--------------------------------------------------------
            starsCYG  47   1  25     1.880169 
Best subsample: 
 [1]  2  4  6 10 13 15 17 19 21 22 25 27 28 29 33 35 36 38 39 41 42 43 44 45 46
Outliers:  6 
[1]  7  9 11 20 30 34
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept     log.Te  
    -8.50       3.05  

Scale estimate 0.456 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
   Min     1Q Median     3Q    Max 
-0.784 -0.214  0.000  0.227  0.592 

Coefficients:
          Estimate Std. Error t value Pr(>|t|)    
Intercept   -8.500      1.926   -4.41  7.8e-05 ***
log.Te       3.046      0.437    6.97  2.4e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.341 on 39 degrees of freedom
Multiple R-Squared: 0.554,	Adjusted R-squared: 0.543 
F-statistic: 48.5 on 1 and 39 DF,  p-value: 2.39e-08 

--------------------------------------------------------
            phosphor  18   2  11     0.245377 
Best subsample: 
 [1]  1  2  3  4  6  7 11 12 14 15 18
Outliers:  1 
[1] 17
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept      inorg    organic  
  60.9149     1.2110     0.0883  

Scale estimate 13.5 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
    Min      1Q  Median      3Q     Max 
-30.297  -3.591  -0.692   4.251  17.116 

Coefficients:
          Estimate Std. Error t value Pr(>|t|)    
Intercept  60.9149    10.1995    5.97  3.4e-05 ***
inorg       1.2110     0.3549    3.41   0.0042 ** 
organic     0.0883     0.2574    0.34   0.7366    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 12.7 on 14 degrees of freedom
Multiple R-Squared: 0.519,	Adjusted R-squared: 0.45 
F-statistic: 7.55 on 2 and 14 DF,  p-value: 0.00597 

--------------------------------------------------------
           stackloss  21   3  13     0.083378 
Best subsample: 
 [1]  5  6  7  8  9 10 11 12 15 16 17 18 19
Outliers:  4 
[1]  1  3  4 21
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
 Intercept    Air.Flow  Water.Temp  Acid.Conc.  
  -37.6525      0.7977      0.5773     -0.0671  

Scale estimate 1.92 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
   Min     1Q Median     3Q    Max 
-2.506 -0.424  0.000  0.576  1.934 

Coefficients:
           Estimate Std. Error t value Pr(>|t|)    
Intercept  -37.6525     4.7321   -7.96  2.4e-06 ***
Air.Flow     0.7977     0.0674   11.83  2.5e-08 ***
Water.Temp   0.5773     0.1660    3.48   0.0041 ** 
Acid.Conc.  -0.0671     0.0616   -1.09   0.2961    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.25 on 13 degrees of freedom
Multiple R-Squared: 0.975,	Adjusted R-squared: 0.969 
F-statistic:  169 on 3 and 13 DF,  p-value: 1.16e-10 

--------------------------------------------------------
             coleman  20   5  13     0.028344 
Best subsample: 
 [1]  1  2  6  7  8  9 11 13 14 15 16 19 20
Outliers:  2 
[1]  3 18
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept    salaryP   fatherWc    sstatus  teacherSc  motherLev  
  29.7577    -1.6985     0.0851     0.6662     1.1840    -4.0668  

Scale estimate 1.12 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
   Min     1Q Median     3Q    Max 
-1.216 -0.389  0.000  0.306  0.984 

Coefficients:
          Estimate Std. Error t value Pr(>|t|)    
Intercept  29.7577     5.5322    5.38  0.00017 ***
salaryP    -1.6985     0.4660   -3.64  0.00336 ** 
fatherWc    0.0851     0.0208    4.09  0.00149 ** 
sstatus     0.6662     0.0382   17.42  6.9e-10 ***
teacherSc   1.1840     0.1643    7.21  1.1e-05 ***
motherLev  -4.0668     0.8487   -4.79  0.00044 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.782 on 12 degrees of freedom
Multiple R-Squared: 0.988,	Adjusted R-squared: 0.983 
F-statistic:  203 on 5 and 12 DF,  p-value: 3.65e-11 

--------------------------------------------------------
            salinity  28   3  16     0.065610 
Best subsample: 
 [1]  2  3  4  6  7 12 14 15 17 18 19 20 21 22 26 27
Outliers:  4 
[1]  5 16 23 24
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept         X1         X2         X3  
   38.063      0.443     -0.206     -1.373  

Scale estimate 1.23 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
   Min     1Q Median     3Q    Max 
-2.482 -0.390  0.000  0.339  1.701 

Coefficients:
          Estimate Std. Error t value Pr(>|t|)    
Intercept   38.063      5.172    7.36  4.1e-07 ***
X1           0.443      0.086    5.15  4.9e-05 ***
X2          -0.206      0.138   -1.50     0.15    
X3          -1.373      0.195   -7.06  7.7e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.03 on 20 degrees of freedom
Multiple R-Squared: 0.899,	Adjusted R-squared: 0.884 
F-statistic: 59.3 on 3 and 20 DF,  p-value: 3.92e-10 

--------------------------------------------------------
            aircraft  23   4  14     0.298554 
Best subsample: 
 [1]  1  5  6  7  8  9 10 11 13 14 15 17 20 23
Outliers:  2 
[1] 16 22
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept         X1         X2         X3         X4  
 9.500740  -3.048797   1.210033   0.001381  -0.000555  

Scale estimate 5.69 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
   Min     1Q Median     3Q    Max 
 -6.67  -2.43   0.00   2.79   6.79 

Coefficients:
           Estimate Std. Error t value Pr(>|t|)   
Intercept  9.500740   5.577532    1.70   0.1078   
X1        -3.048797   0.919147   -3.32   0.0044 **
X2         1.210033   0.649230    1.86   0.0808 . 
X3         0.001381   0.000392    3.52   0.0028 **
X4        -0.000555   0.000328   -1.69   0.1102   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 4.35 on 16 degrees of freedom
Multiple R-Squared: 0.826,	Adjusted R-squared: 0.782 
F-statistic:   19 on 4 and 16 DF,  p-value: 6.47e-06 

--------------------------------------------------------
            delivery  25   2  14     0.112945 
Best subsample: 
 [1]  2  5  6  7  8 10 12 13 14 15 17 21 22 25
Outliers:  3 
[1]  1  9 24
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept     n.prod   distance  
   3.7196     1.4058     0.0163  

Scale estimate 2.38 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
    Min      1Q  Median      3Q     Max 
-5.0321 -1.0306 -0.0124  0.3474  4.2371 

Coefficients:
          Estimate Std. Error t value Pr(>|t|)    
Intercept  3.71959    0.91011    4.09  0.00063 ***
n.prod     1.40578    0.13128   10.71  1.7e-09 ***
distance   0.01625    0.00301    5.40  3.3e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.32 on 19 degrees of freedom
Multiple R-Squared: 0.962,	Adjusted R-squared: 0.958 
F-statistic:  243 on 2 and 19 DF,  p-value: 2.9e-14 

--------------------------------------------------------
                wood  20   5  13     0.070258 
Best subsample: 
 [1]  2  3  9 10 11 12 13 14 15 16 17 18 20
Outliers:  4 
[1]  4  6  8 19
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept         x1         x2         x3         x4         x5  
    0.377      0.217     -0.085     -0.564     -0.400      0.607  

Scale estimate 0.0124 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
     Min       1Q   Median       3Q      Max 
-0.00928 -0.00177  0.00000  0.00115  0.01300 

Coefficients:
          Estimate Std. Error t value Pr(>|t|)    
Intercept   0.3773     0.0540    6.99  3.8e-05 ***
x1          0.2174     0.0421    5.16  0.00042 ***
x2         -0.0850     0.1977   -0.43  0.67634    
x3         -0.5643     0.0435  -12.98  1.4e-07 ***
x4         -0.4003     0.0654   -6.12  0.00011 ***
x5          0.6074     0.0786    7.73  1.6e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.00745 on 10 degrees of freedom
Multiple R-Squared: 0.958,	Adjusted R-squared: 0.937 
F-statistic:   46 on 5 and 10 DF,  p-value: 1.4e-06 

--------------------------------------------------------
                 hbk  75   3  40     3.724554 
Best subsample: 
 [1] 11 12 14 16 17 18 20 25 26 30 31 32 33 34 35 36 37 39 40 41 42 44 45 46 48
[26] 50 55 56 58 59 60 61 63 64 66 67 69 71 72 74
Outliers:  10 
 [1]  1  2  3  4  5  6  7  8  9 10
-------------

Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Coefficients:
Intercept         X1         X2         X3  
  -0.1805     0.0814     0.0399    -0.0517  

Scale estimate 0.744 


Call:
ltsReg.formula(formula = form, data = dataset, mcd = FALSE)

Residuals (from reweighted LS):
   Min     1Q Median     3Q    Max 
-0.926 -0.396  0.000  0.397  1.011 

Coefficients:
          Estimate Std. Error t value Pr(>|t|)  
Intercept  -0.1805     0.1044   -1.73    0.089 .
X1          0.0814     0.0667    1.22    0.227  
X2          0.0399     0.0405    0.99    0.328  
X3         -0.0517     0.0354   -1.46    0.149  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.557 on 61 degrees of freedom
Multiple R-Squared: 0.0428,	Adjusted R-squared: -0.00429 
F-statistic: 0.909 on 3 and 61 DF,  p-value: 0.442 

--------------------------------------------------------
========================================================
> if(FALSE) { ## FIXME: These *FAIL* !
+ doLTSdata(nrep = 12, time = FALSE)
+ doLTSdata(nrep = 12, time = FALSE, method = "MASS")
+ }
> 
> test_rsquared()

Call:
ltsReg.default(x = y1, y = x1, alpha = 0.8)

Coefficients:
Intercept         y1  
     25.9        5.3  

Scale estimate 18 


Call:
ltsReg.default(x = y1, y = x1, intercept = FALSE, alpha = 0.8)

Coefficients:
  y1  
31.4  

Scale estimate 24.6 

Warning messages:
1: In covMcd(X, alpha = alpha, use.correction = use.correction) :
  Initial scale 0 because more than 'h' (=16) observations are identical.
2: In covMcd(X, alpha = alpha, use.correction = use.correction) :
  Initial scale 0 because more than 'h' (=16) observations are identical.
> test_location()

Call:
ltsReg.default(y = Y)

Coefficients:
[1]  44.6

Scale estimate 19.7 


Call:
ltsReg.default(y = Y, intercept = TRUE)

Coefficients:
[1]  44.6

Scale estimate 19.7 


Call:
ltsReg.default(y = Y, intercept = FALSE)

Coefficients:
[1]  44.6

Scale estimate 20 


Call:
ltsReg.default(y = Y, alpha = 1)

Coefficients:
[1]  33

Scale estimate 19.3 


Call:
ltsReg.formula(formula = Y ~ 1)

Coefficients:
[1]  44.6

Scale estimate 19.7 


Call:
ltsReg.formula(formula = Y ~ 0)

No coefficients

Call:
ltsReg.formula(formula = Y ~ 1, alpha = 1)

Coefficients:
[1]  33

Scale estimate 19.3 

> 
> if(length(W <- warnings())) print(if(getRversion() >= "3.5") summary(W) else W)
2 identical warnings:
In covMcd(X, alpha = alpha, use.correction = use.correction) :
  Initial scale 0 because more than 'h' (=16) observations are identical.
> 
> cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''
Time elapsed:  0.332 0.058 0.463 0.002 0.001 
> 
> proc.time()
   user  system elapsed 
  0.334   0.059   0.463