Giter Club home page Giter Club logo

robust's People

Contributors

valentint avatar

Watchers

 avatar

robust's Issues

One example fails: Error: data.matrix(woodmod.dat) == data.matrix(wood[, 1:5]) are not all TRUE

R version 4.2.3 (2023-03-15) -- "Shortstop Beagle"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: powerpc-apple-darwin10.8.0 (32-bit)

> pkgname <- "robust"
> source(file.path(R.home("share"), "R", "examples-header.R"))
> options(warn = 1)
> library('robust')
Loading required package: fit.models
> 
> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("OverlaidDenPlot.fdfm")
> ### * OverlaidDenPlot.fdfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: overlaidDenPlot.fdfm
> ### Title: Overlaid Density Plot
> ### Aliases: overlaidDenPlot.fdfm
> ### Keywords: hplot
> 
> ### ** Examples
> 
>   data(los, package="robustbase")
>   
>  ## Not run: 
> ##D  
> ##D   los.fm <- fit.models(c(Robust = "fitdstnRob", MLE = "fitdstn"),
> ##D                          x = los, densfun = "gamma")
> ##D 
> ##D   
> ##D   los.fm <- fit.models(c(Robust = "fitdstnRob", MLE = "fitdstn"),
> ##D                          x = los, densfun = "weibull")
> ##D                          
> ##D   overlaidDenPlot.fdfm(los.fm, xlab = "x-axis label", ylab = "y-axis label",
> ##D                        main = "Plot Title")
> ##D  
> ## End(Not run)
> 
> 
> 
> cleanEx()
> nameEx("anova.glmRob")
> ### * anova.glmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: anova.glmRob
> ### Title: ANOVA for Robust Generalized Linear Model Fits
> ### Aliases: anova.glmRob anova.glmRoblist
> ### Keywords: robust regression methods
> 
> ### ** Examples
> 
> data(breslow.dat)
> 
> bres.int <- glmRob(sumY ~ Age10 + Base4*Trt, family = poisson(), data = breslow.dat)
> anova(bres.int)
Analysis of Deviance Table

poisson model

Response: sumY

Terms added sequentially (first to last)
          Df Deviance Resid. Df Resid. Dev
NULL                         58    11983.1
Age10      1   9125.7        57     2857.5
Base4      1    803.0        56     2054.5
Trt        1   -884.6        55     2939.1
Base4:Trt  1   -949.1        54     3888.2
> 
> bres.main <- glmRob(sumY ~ Age10 + Base4 + Trt, family = poisson(), data = breslow.dat)
> anova(bres.main, bres.int)
                Terms Resid. Df Resid. Dev       Test Df  Deviance
1 Age10 + Base4 + Trt        55   2939.072            NA        NA
2 Age10 + Base4 * Trt        54   3888.204 +Base4:Trt  1 -949.1315
> 
> 
> 
> cleanEx()
> nameEx("anova.lmRob")
> ### * anova.lmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: anova.lmRob
> ### Title: ANOVA for Robust Linear Model Fits
> ### Aliases: anova.lmRob anova.lmRoblist
> ### Keywords: robust regression methods
> 
> ### ** Examples
> 
> data(stack.dat)
> stack.small <- lmRob(Loss ~ Water.Temp + Acid.Conc., data = stack.dat)
> stack.full <- lmRob(Loss ~ ., data = stack.dat)
> anova(stack.full)

Terms added sequentially (first to last)

            Chisq Df RobustF     Pr(F)    
(Intercept)        1                      
Air.Flow           1  41.228 6.026e-11 ***
Water.Temp         1   6.522  0.009257 ** 
Acid.Conc.         1   0.551  0.449386    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> anova(stack.full, stack.small)

Response: Loss
     Terms     Df RobustF     Pr(F)    
[1,]     1   1                         
[2,]     2   1  1  27.354 9.839e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
> 
> 
> cleanEx()
> nameEx("breslow.dat")
> ### * breslow.dat
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: breslow.dat
> ### Title: Breslow Data
> ### Aliases: breslow.dat
> ### Keywords: datasets
> 
> ### ** Examples
> 
> data(breslow.dat)
> 
> 
> 
> cleanEx()
> nameEx("covClassic")
> ### * covClassic
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: covClassic
> ### Title: Classical Covariance Estimation
> ### Aliases: covClassic
> ### Keywords: robust multivariate
> 
> ### ** Examples
> 
>   data(stack.dat)
>   covClassic(stack.dat)
Call:
covClassic(data = stack.dat)

Classical Estimate of Covariance: 
             Loss Air.Flow Water.Temp Acid.Conc.
Loss       103.46    85.76     28.148     21.793
Air.Flow    85.76    84.06     22.657     24.571
Water.Temp  28.15    22.66      9.990      6.621
Acid.Conc.  21.79    24.57      6.621     28.714

Classical Estimate of Location: 
      Loss   Air.Flow Water.Temp Acid.Conc. 
     17.52      60.43      21.10      86.29 
> 
> 
> 
> cleanEx()
> nameEx("covRob")
> ### * covRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: covRob
> ### Title: Robust Covariance/Correlation Matrix Estimation
> ### Aliases: covRob
> ### Keywords: multivariate robust
> 
> ### ** Examples
> 
>   data(stackloss)
>   covRob(stackloss)
Call:
covRob(data = stackloss)

Robust Estimate of Covariance: 
           Air.Flow Water.Temp Acid.Conc. stack.loss
Air.Flow      33.93     11.203     22.135      29.41
Water.Temp    11.20      8.298      8.794      12.03
Acid.Conc.    22.14      8.794     37.887      17.60
stack.loss    29.41     12.030     17.605      28.17

Robust Estimate of Location: 
  Air.Flow Water.Temp Acid.Conc. stack.loss 
     56.92      20.43      86.29      13.73 
> 
> 
> 
> cleanEx()
> nameEx("covRob.control")
> ### * covRob.control
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: covRob.control
> ### Title: Control Parameters for Robust Covariance Estimation
> ### Aliases: covRob.control
> ### Keywords: utilities
> 
> ### ** Examples
> 
>   mcd.control <- covRob.control("mcd", quan = 0.75, ntrial = 1000)
> 
>   ds.control <- covRob.control("donostah", prob = 0.95)
> 
>   qc.control <- covRob.control("pairwiseqc")
> 
> 
> 
> cleanEx()
> nameEx("ddPlot.covfm")
> ### * ddPlot.covfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: ddPlot.covfm
> ### Title: Distance - Distance Plot
> ### Aliases: ddPlot.covfm
> ### Keywords: hplot
> 
> ### ** Examples
> 
>  data(woodmod.dat)
>  woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+                         data = woodmod.dat)
>  ddPlot.covfm(woodm.fm, main = "Plot Title", xlab = "x-axis label",
+               ylab = "y-axis label", pch = 4, col = "purple")
> 
> 
> 
> cleanEx()
> nameEx("distancePlot.covfm")
> ### * distancePlot.covfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: distancePlot.covfm
> ### Title: Side-by-Side Mahalanobis Distance Plot
> ### Aliases: distancePlot.covfm
> ### Keywords: hplot
> 
> ### ** Examples
> 
>   data(woodmod.dat)
>   woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+                          data = woodmod.dat)
>   distancePlot.covfm(woodm.fm, main = "Plot Title", xlab = "x-axis label",
+                      ylab = "y-axis label", pch = 4, col = "purple")
> 
> 
> 
> cleanEx()
> nameEx("drop1.lmRob")
> ### * drop1.lmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: drop1.lmRob
> ### Title: Compute an Anova Object by Dropping Terms
> ### Aliases: drop1.lmRob
> ### Keywords: robust regression methods
> 
> ### ** Examples
> 
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat) 
> drop1(stack.rob) 

Single term deletions

Model:
Loss ~ Air.Flow + Water.Temp + Acid.Conc.

scale:  1.837073 

           Df   RFPE
<none>        16.032
Air.Flow    1 36.213
Water.Temp  1 20.829
Acid.Conc.  1 16.049
> 
> 
> 
> cleanEx()
> nameEx("ellipsesPlot.covfm")
> ### * ellipsesPlot.covfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: ellipsesPlot.covfm
> ### Title: Ellipses Plot - Visual Correlation Matrix Comparison
> ### Aliases: ellipsesPlot.covfm
> ### Keywords: hplot
> 
> ### ** Examples
> 
>   data(woodmod.dat)
>   woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+                          data = woodmod.dat)
>   ellipsesPlot.covfm(woodm.fm)
> 
> 
> 
> cleanEx()
> nameEx("glmRob")
> ### * glmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: glmRob
> ### Title: Fit a Robust Generalized Linear Model
> ### Aliases: glmRob
> ### Keywords: robust regression models
> 
> ### ** Examples
> 
> data(breslow.dat)
> 
> glmRob(sumY ~ Age10 + Base4*Trt, family = poisson(),
+        data = breslow.dat, method = "cubif")
Call:
glmRob(formula = sumY ~ Age10 + Base4 * Trt, family = poisson(), 
    data = breslow.dat, method = "cubif")

Coefficients:
       (Intercept)              Age10              Base4       Trtprogabide 
           1.83516            0.12081            0.13915           -0.39279 
Base4:Trtprogabide 
           0.02182 

Degrees of Freedom: 59 Total; 54 Residual
Residual Deviance: 3888 
> 
> 
> 
> cleanEx()
> nameEx("glmRob.mallows")
> ### * glmRob.mallows
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: glmRob.mallows
> ### Title: Mallows Type Estimator
> ### Aliases: glmRob.mallows
> ### Keywords: robust regression
> 
> ### ** Examples
> 
> data(mallows.dat)
> 
> glmRob(y ~ a + b + c, data = mallows.dat, family = binomial(), method = 'mallows')
Call:
glmRob(formula = y ~ a + b + c, family = binomial(), data = mallows.dat, 
    method = "mallows")

Coefficients:
(Intercept)           a           b           c 
   -2.04642     0.10810     0.08633     0.12584 

Degrees of Freedom: 70 Total; 66 Residual
Residual Deviance: 40.06 
> 
> 
> 
> cleanEx()
> nameEx("glmRob.misclass")
> ### * glmRob.misclass
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: glmRob.misclass
> ### Title: Consistent Misclassification Estimator
> ### Aliases: glmRob.misclass
> ### Keywords: robust regression
> 
> ### ** Examples
> 
> data(leuk.dat)
> 
> glmRob(y ~ ag + wbc, data = leuk.dat, family = binomial(), method = 'misclass')
Call:
glmRob(formula = y ~ ag + wbc, family = binomial(), data = leuk.dat, 
    method = "misclass")

Coefficients:
(Intercept)          ag         wbc 
 -1.265e+00   2.219e+00  -3.276e-05 

Degrees of Freedom: 33 Total; 30 Residual
Residual Deviance: 29.59 
> 
> 
> 
> cleanEx()
> nameEx("leuk.dat")
> ### * leuk.dat
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: leuk.dat
> ### Title: Leuk Data
> ### Aliases: leuk.dat
> ### Keywords: datasets
> 
> ### ** Examples
> 
> data(leuk.dat)
> 
> 
> 
> cleanEx()
> nameEx("lmRob")
> ### * lmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: lmRob
> ### Title: High Breakdown and High Efficiency Robust Linear Regression
> ### Aliases: lmRob
> ### Keywords: robust regression models
> 
> ### ** Examples
> 
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> 
> 
> 
> cleanEx()
> nameEx("lmRob.RFPE")
> ### * lmRob.RFPE
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: lmRob.RFPE
> ### Title: Robust Final Prediction Errors
> ### Aliases: lmRob.RFPE
> ### Keywords: robust regression
> 
> ### ** Examples
> 
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> lmRob.RFPE(stack.rob)
[1] 16.03201
> 
> 
> 
> cleanEx()
> nameEx("lmRob.control")
> ### * lmRob.control
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: lmRob.control
> ### Title: Control Parameters for Robust Linear Regression
> ### Aliases: lmRob.control
> ### Keywords: robust regression
> 
> ### ** Examples
> 
> data(stack.dat)
> my.control <- lmRob.control(weight=c("Bisquare","Optimal"))
> stack.bo <- lmRob(Loss ~ ., data = stack.dat, control = my.control)
> 
> 
> 
> cleanEx()
> nameEx("lsRobTest")
> ### * lsRobTest
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: lsRobTest
> ### Title: Bias Test for Least-Squares Regression Estimates
> ### Aliases: lsRobTest
> ### Keywords: robust regression
> 
> ### ** Examples
> 
> rob.fit <- lmRob(stack.loss ~ ., data = stackloss)
> lsRobTest(rob.fit)
Test for least squares bias
H0: composite normal/non-normal regression error distribution

Individual coefficient tests:
                LS   Robust    Delta Std. Error    Stat p-value
Air.Flow    0.7156  0.79769 -0.08205     0.1353 -0.6064 0.54427
Water.Temp  1.2953  0.57734  0.71795     0.3366  2.1332 0.03291
Acid.Conc. -0.1521 -0.06706 -0.08506     0.1200 -0.7091 0.47824

Joint test for bias:
Test statistic: 6.61 on 3 DF, p-value: 0.08541
> lsRobTest(rob.fit, test = "T1")
Test for least squares bias
H0: normal regression error distribution

Individual coefficient tests:
                LS   Robust    Delta Std. Error   Stat   p-value
Air.Flow    0.7156  0.79769 -0.08205    0.02101 -3.906 9.388e-05
Water.Temp  1.2953  0.57734  0.71795    0.05225 13.741 5.764e-43
Acid.Conc. -0.1521 -0.06706 -0.08506    0.01862 -4.568 4.928e-06

Joint test for bias:
Test statistic: 274.3 on 3 DF, p-value: 0
> 
> 
> 
> cleanEx()
> nameEx("mallows.dat")
> ### * mallows.dat
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: mallows.dat
> ### Title: Mallows Data
> ### Aliases: mallows.dat
> ### Keywords: datasets
> 
> ### ** Examples
> 
> data(mallows.dat)
> 
> 
> 
> cleanEx()
> nameEx("plot.covfm")
> ### * plot.covfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.covfm
> ### Title: Plot Method
> ### Aliases: plot.covfm plot.covRob plot.covClassic
> ### Keywords: methods hplot
> 
> ### ** Examples
> 
> data(woodmod.dat)
> 
> woodm.cov <- covClassic(woodmod.dat)
> woodm.covRob <- covRob(woodmod.dat)
> 
> plot(woodm.cov)
> plot(woodm.covRob)
> 
> woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+                        data = woodmod.dat)
> plot(woodm.fm)
> 
> 
> 
> cleanEx()
> nameEx("plot.fdfm")
> ### * plot.fdfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.fdfm
> ### Title: fdfm Plot Method
> ### Aliases: plot.fdfm
> ### Keywords: hplot
> 
> ### ** Examples
> 
>   data(los, package = "robustbase")
>   los.fm <- fit.models(c(Robust = "fitdstnRob", MLE = "fitdstn"),
+                          x = los, densfun = "gamma")
>   plot(los.fm)
> 
> 
> 
> cleanEx()
> nameEx("plot.lmRob")
> ### * plot.lmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.lmRob
> ### Title: Diagnostic Regression Plots
> ### Aliases: plot.lmRob
> ### Keywords: methods hplot
> 
> ### ** Examples
> 
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> plot(stack.rob, which.plots = 6)
> 
> 
> 
> cleanEx()
> nameEx("predict.glmRob")
> ### * predict.glmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: predict.glmRob
> ### Title: Predict Method for Robust Generalized Linear Model Fits
> ### Aliases: predict.glmRob
> ### Keywords: robust regression methods
> 
> ### ** Examples
> 
> data(breslow.dat)
> bres.rob <- glmRob(sumY ~ Age10 + Base4 * Trt, family = poisson(), data = breslow.dat)
> predict(bres.rob)
       1        2        3        4        5        6        7        8 
2.592342 2.580261 2.345916 2.548386 4.396928 3.124781 2.627130 4.151528 
       9       10       11       12       13       14       15       16 
3.082281 2.521311 4.079040 3.273100 2.739205 3.731164 5.175793 3.888652 
      17       18       19       20       21       22       23       24 
2.799611 6.071102 2.847937 2.784617 2.602967 2.401954 2.813149 3.111243 
      25       26       27       28       29       30       31       32 
4.110915 2.631499 2.412579 3.735964 4.718229 3.358170 2.448596 2.207231 
      33       34       35       36       37       38       39       40 
2.424433 2.698131 3.052314 2.428606 2.211229 4.380213 3.358083 2.062342 
      41       42       43       44       45       46       47       48 
2.605566 2.448770 3.692188 3.144792 3.394414 2.026098 3.205198 2.187066 
      49       50       51       52       53       54       55       56 
7.784706 2.714298 3.394327 3.152962 3.949632 2.903514 2.472846 2.641810 
      57       58       59 
2.702129 2.400445 2.372284 
> 
> 
> 
> cleanEx()
> nameEx("predict.lmRob")
> ### * predict.lmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: predict.lmRob
> ### Title: Use predict() on an lmRob Object
> ### Aliases: predict.lmRob
> ### Keywords: robust regression methods
> 
> ### ** Examples
> 
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> predict(stack.rob)
        1         2         3         4         5         6         7         8 
35.782223 35.849283 30.572054 19.825981 18.671300 19.248641 19.423620 19.423620 
        9        10        11        12        13        14        15        16 
16.057899 13.640618 13.037076 12.526796 13.506497 13.346176  6.655592  6.856772 
       17        18        19        20        21 
 8.372955  7.903534  8.413814 13.065807 23.629863 
> predict(stack.rob, newdata = stack.dat[c(1,2,4,21), ], se.fit = TRUE)
$fit
       1        2        4       21 
35.78222 35.84928 19.82598 23.62986 

$se.fit
        1         2         4        21 
1.0869527 1.1059685 0.5557136 0.9526912 

$residual.scale
[1] 1.837073

$df
[1] 17

> 
> 
> 
> cleanEx()
> nameEx("qqPlot.fdfm")
> ### * qqPlot.fdfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: qqPlot.fdfm
> ### Title: Comparison Quantile-Quantile Plot
> ### Aliases: qqPlot.fdfm
> ### Keywords: hplot
> 
> ### ** Examples
> 
>   data(los, package = "robustbase")
>   los.fm <- fit.models(c(Robust = "fitdstnRob", MLE = "fitdstn"),
+                          x = los, densfun = "gamma")
>   qqPlot.fdfm(los.fm, xlab = "x-axis label", ylab = "y-axis label",
+               main = "Plot Title", pch = 4, col = "purple")
> 
> 
> 
> cleanEx()
> nameEx("screePlot.covfm")
> ### * screePlot.covfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: screePlot.covfm
> ### Title: Comparison Screeplot
> ### Aliases: screePlot.covfm
> ### Keywords: hplot
> 
> ### ** Examples
> 
>   data(woodmod.dat)
>   woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+                          data = woodmod.dat)
>   screePlot.covfm(woodm.fm, main = "Plot Title", xlab = "x-axis label",
+                   ylab = "y-axis label", pch = 4:5)
> 
> 
> 
> cleanEx()
> nameEx("stack.dat")
> ### * stack.dat
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: stack.dat
> ### Title: Brownlee's Stack-Loss Data
> ### Aliases: stack.dat
> ### Keywords: datasets
> 
> ### ** Examples
> 
>   data(stack.dat)
>   stack.dat
   Loss Air.Flow Water.Temp Acid.Conc.
1    42       80         27         89
2    37       80         27         88
3    37       75         25         90
4    28       62         24         87
5    18       62         22         87
6    18       62         23         87
7    19       62         24         93
8    20       62         24         93
9    15       58         23         87
10   14       58         18         80
11   14       58         18         89
12   13       58         17         88
13   11       58         18         82
14   12       58         19         93
15    8       50         18         89
16    7       50         18         86
17    8       50         19         72
18    8       50         19         79
19    9       50         20         80
20   15       56         20         82
21   15       70         20         91
> 
> 
> 
> cleanEx()
> nameEx("step.lmRob")
> ### * step.lmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: step.lmRob
> ### Title: Build a Model in a Stepwise Fashion
> ### Aliases: step.lmRob
> ### Keywords: robust regression methods
> 
> ### ** Examples
> 
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> 
> ## The default behavior is to try dropping all terms ##
> step.lmRob(stack.rob)
Start:  RFPE= 16.032 
 Loss ~ Air.Flow + Water.Temp + Acid.Conc. 


Single term deletions

Model:
Loss ~ Air.Flow + Water.Temp + Acid.Conc.

scale:  1.837073 

           Df   RFPE
<none>        16.032
Air.Flow    1 36.213
Water.Temp  1 20.829
Acid.Conc.  1 16.049

Call:
lmRob(formula = Loss ~ ., data = stack.dat)

Coefficients:
(Intercept)     Air.Flow   Water.Temp   Acid.Conc.  
  -37.65246      0.79769      0.57734     -0.06706  

> 
> ## Keep Water.Temp in the model ##
> my.scope <- list(lower = . ~ Water.Temp, upper = . ~ .)
> step.lmRob(stack.rob, scope = my.scope)
Start:  RFPE= 16.032 
 Loss ~ Air.Flow + Water.Temp + Acid.Conc. 


Single term deletions

Model:
Loss ~ Air.Flow + Water.Temp + Acid.Conc.

scale:  1.837073 

           Df   RFPE
<none>        16.032
Air.Flow    1 36.213
Acid.Conc.  1 16.049

Call:
lmRob(formula = Loss ~ ., data = stack.dat)

Coefficients:
(Intercept)     Air.Flow   Water.Temp   Acid.Conc.  
  -37.65246      0.79769      0.57734     -0.06706  

> 
> 
> 
> cleanEx()
> nameEx("summary.covfm")
> ### * summary.covfm
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: summary.covfm
> ### Title: Summary Method
> ### Aliases: summary.covClassic summary.covRob summary.covfm
> ### Keywords: methods
> 
> ### ** Examples
> 
>   data(woodmod.dat)
>   woodm.cov <- covClassic(woodmod.dat)
> ## IGNORE_RDIFF_BEGIN
>   summary(woodm.cov)
Call:
covClassic(data = woodmod.dat)

Classical Estimate of Covariance: 
           V1         V2        V3         V4         V5
V1  0.0082920 -0.0002912  0.003602  0.0026908 -0.0028684
V2 -0.0002912  0.0004888 -0.000352 -0.0008388  0.0006124
V3  0.0036022 -0.0003520  0.004185  0.0015788 -0.0016916
V4  0.0026908 -0.0008388  0.001579  0.0039462 -0.0007920
V5 -0.0028684  0.0006124 -0.001692 -0.0007920  0.0027570

Classical Estimate of Location: 
    V1     V2     V3     V4     V5 
0.5509 0.1330 0.5087 0.5112 0.9070 

Eigenvalues: 
  Eval. 1   Eval. 2   Eval. 3   Eval. 4   Eval. 5 
0.0128527 0.0029621 0.0021125 0.0016344 0.0001075 

Squared Mahalanobis Distances: 
    1     2     3     4     5     6     7     8     9    10    11    12    13 
4.327 1.552 3.224 3.959 3.277 3.974 9.124 4.536 5.665 7.588 5.075 6.833 4.506 
   14    15    16    17    18    19    20 
1.500 1.945 9.049 4.548 4.637 4.599 5.084 
> ## IGNORE_RDIFF_END
> 
>   woodm.covRob <- covRob(woodmod.dat)
>   summary(woodm.covRob)
Call:
covRob(data = woodmod.dat)

Robust Estimate of Covariance: 
          V1         V2         V3         V4         V5
V1  0.038232  0.0066282 -0.0021650 -0.0015136 -0.0048570
V2  0.006628  0.0016512  0.0001382 -0.0010400 -0.0003837
V3 -0.002165  0.0001382  0.0036709  0.0001514  0.0015113
V4 -0.001514 -0.0010400  0.0001514  0.0048313 -0.0014409
V5 -0.004857 -0.0003837  0.0015113 -0.0014409  0.0044166

Robust Estimate of Location: 
    V1     V2     V3     V4     V5 
0.5693 0.1189 0.5093 0.5399 0.8964 

Eigenvalues: 
  Eval. 1   Eval. 2   Eval. 3   Eval. 4   Eval. 5 
0.0402612 0.0063495 0.0039998 0.0019171 0.0002747 

Squared Robust Distances: 
 [1]  1.2996  0.3348  0.4099 15.8192  0.4578 18.0052  8.5876 24.2857  8.1617
[10]  5.1665  2.0412  5.3157  5.7099  0.2672  0.3173  5.5845  3.4097  0.4362
[19] 25.9520  3.5364
> 
>   woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+                          data = woodmod.dat)
>   summary(woodm.fm)

Calls: 
Robust: covRob(data = woodmod.dat)
Classical: covClassic(data = woodmod.dat)

Comparison of Covariance/Correlation Estimates:
 (unique correlation terms) 
             [1,1]      [2,1]     [3,1]     [4,1]     [5,1]     [2,2]
Robust    0.038232  0.0066282 -0.002165 -0.001514 -0.004857 0.0016512
Classical 0.008292 -0.0002912  0.003602  0.002691 -0.002868 0.0004888
               [3,2]      [4,2]      [5,2]    [3,3]     [4,3]     [5,3]
Robust     0.0001382 -0.0010400 -0.0003837 0.003671 0.0001514  0.001511
Classical -0.0003520 -0.0008388  0.0006124 0.004185 0.0015788 -0.001692
             [4,4]     [5,4]    [5,5]
Robust    0.004831 -0.001441 0.004417
Classical 0.003946 -0.000792 0.002757

Comparison of center Estimates: 
              V1     V2     V3     V4     V5
Robust    0.5693 0.1189 0.5093 0.5399 0.8964
Classical 0.5509 0.1330 0.5087 0.5112 0.9070

Comparison of Eigenvalues: 
          Eval. 1  Eval. 2  Eval. 3  Eval. 4   Eval. 5
Robust    0.04026 0.006349 0.004000 0.001917 0.0002747
Classical 0.01285 0.002962 0.002112 0.001634 0.0001075
> 
> 
> 
> cleanEx()
> nameEx("summary.glmRob")
> ### * summary.glmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: summary.glmRob
> ### Title: Summarizing Robust Generalized Linear Model Fits
> ### Aliases: summary.glmRob
> ### Keywords: methods robust regression
> 
> ### ** Examples
> 
> data(breslow.dat)
> bres.rob <- glmRob(sumY ~ Age10 + Base4*Trt, family = poisson(), data = breslow.dat)
> bres.sum <- summary(bres.rob)
> bres.sum

Call: glmRob(formula = sumY ~ Age10 + Base4 * Trt, family = poisson(), 
    data = breslow.dat)
Deviance Residuals:
      Min        1Q    Median        3Q       Max 
-54.31624  -1.48734   0.04103   0.87948   8.92507 

Coefficients:
                   Estimate Std. Error z value  Pr(>|z|)
(Intercept)         1.83516    0.28542  6.4296 1.279e-10
Age10               0.12081    0.07495  1.6118 1.070e-01
Base4               0.13915    0.03541  3.9298 8.501e-05
Trtprogabide       -0.39279    0.22101 -1.7772 7.554e-02
Base4:Trtprogabide  0.02182    0.04003  0.5451 5.857e-01

(Dispersion Parameter for poisson family taken to be 1 )

    Null Deviance: 11983 on 58 degrees of freedom

Residual Deviance: 3888.204 on 54 degrees of freedom

Number of Iterations: 9 

Correlation of Coefficients:
                   (Intercept) Age10    Base4    Trtprogabide
Age10              -0.80956                                  
Base4              -0.62030     0.10855                      
Trtprogabide       -0.46447     0.02404  0.69012             
Base4:Trtprogabide  0.52264    -0.06402 -0.88082 -0.89436    
> 
> 
> 
> cleanEx()
> nameEx("summary.lmRob")
> ### * summary.lmRob
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: summary.lmRob
> ### Title: Summarizing Robust Linear Model Fits
> ### Aliases: summary.lmRob
> ### Keywords: methods robust regression
> 
> ### ** Examples
> 
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat) 
> stack.sum <- summary(stack.rob)
> stack.sum

Call:
lmRob(formula = Loss ~ ., data = stack.dat)

Residuals:
    Min      1Q  Median      3Q     Max 
-8.6299 -0.6713  0.3594  1.1507  8.1740 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -37.65246    5.00256  -7.527 8.29e-07 ***
Air.Flow      0.79769    0.07129  11.189 2.91e-09 ***
Water.Temp    0.57734    0.17546   3.291  0.00432 ** 
Acid.Conc.   -0.06706    0.06512  -1.030  0.31757    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.837 on 17 degrees of freedom
Multiple R-Squared: 0.6205 

Test for Bias:
            statistic p-value
M-estimate      2.751  0.6004
LS-estimate     2.640  0.6197
> stack.bse <- summary(stack.rob, bootstrap.se = TRUE)
> stack.bse

Call:
lmRob(formula = Loss ~ ., data = stack.dat)

Residuals:
    Min      1Q  Median      3Q     Max 
-8.6299 -0.6713  0.3594  1.1507  8.1740 

Coefficients:
             Estimate Std. Error Bootstrap SE t value Pr(>|t|)    
(Intercept) -37.65246    5.00256      4.43790  -7.527 8.29e-07 ***
Air.Flow      0.79769    0.07129      0.05086  11.189 2.91e-09 ***
Water.Temp    0.57734    0.17546      0.13551   3.291  0.00432 ** 
Acid.Conc.   -0.06706    0.06512      0.05842  -1.030  0.31757    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.837 on 17 degrees of freedom
Multiple R-Squared: 0.6205 

Test for Bias:
            statistic p-value
M-estimate      2.751  0.6004
LS-estimate     2.640  0.6197
> 
> 
> 
> cleanEx()
> nameEx("weight.funs")
> ### * weight.funs
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: weight.funs
> ### Title: Weight Functions Psi, Rho, Chi
> ### Aliases: psi.weight rho.weight psp.weight chi.weight
> ### Keywords: robust
> 
> ### ** Examples
> 
> x <- seq(-4,4, length=401)
> f.x <- cbind(psi = psi.weight(x), psp = psp.weight(x),
+              chi = chi.weight(x), rho = rho.weight(x))
> es <- expression(psi(x), {psi*minute}(x), chi(x), rho(x))
> leg <- as.expression(lapply(seq_along(es), function(i)
+           substitute(C == E, list(C=colnames(f.x)[i], E=es[[i]]))))
> matplot(x, f.x, type = "l", lwd = 1.5,
+         main = "psi.weight(.) etc -- 'optimal'")
> abline(h = 0, v = 0, lwd = 2, col = "#D3D3D380") # opaque gray
> legend("bottom", leg, inset = .01,
+        lty = 1:4, col = 1:4, lwd = 1.5, bg = "#FFFFFFC0")
> 
> 
> 
> cleanEx()
> nameEx("woodmod.dat")
> ### * woodmod.dat
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: woodmod.dat
> ### Title: Modified Wood Data
> ### Aliases: woodmod.dat
> ### Keywords: datasets
> 
> ### ** Examples
> 
>   data(woodmod.dat)
>   woodmod.dat
      V1     V2    V3    V4    V5
1  0.573 0.1059 0.465 0.538 0.841
2  0.651 0.1356 0.527 0.545 0.887
3  0.606 0.1273 0.494 0.521 0.920
4  0.437 0.1591 0.446 0.423 0.992
5  0.547 0.1135 0.531 0.519 0.915
6  0.444 0.1628 0.429 0.411 0.984
7  0.489 0.1231 0.562 0.455 0.824
8  0.413 0.1673 0.418 0.430 0.978
9  0.536 0.1182 0.592 0.464 0.854
10 0.685 0.1564 0.631 0.564 0.914
11 0.664 0.1588 0.506 0.481 0.867
12 0.703 0.1335 0.519 0.484 0.812
13 0.653 0.1395 0.625 0.519 0.892
14 0.586 0.1114 0.505 0.565 0.889
15 0.534 0.1143 0.521 0.570 0.889
16 0.523 0.1320 0.505 0.612 0.919
17 0.580 0.1249 0.546 0.608 0.954
18 0.448 0.1028 0.522 0.534 0.918
19 0.417 0.1687 0.405 0.415 0.981
20 0.528 0.1057 0.424 0.566 0.909
> 
>   data(wood, package = "robustbase")
>   stopifnot(data.matrix(woodmod.dat) ==
+             data.matrix(wood [,1:5]))
Error: data.matrix(woodmod.dat) == data.matrix(wood[, 1:5]) are not all TRUE
Execution halted

`predict` doesn't work for `glmRob()` with new data

predict doesn't work correctly for glmRob objects if a new dataset is supplied.

library(robust)
#> Loading required package: fit.models
data(breslow.dat)

bres.rob <- glmRob(sumY ~ Age10 + Base4 * Trt, family = poisson(),
                   data = breslow.dat)
predict(bres.rob, newdata = breslow.dat[1,])
#> Error in NextMethod("predict"): no method to invoke

Created on 2022-09-30 with reprex v2.0.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.