Running ‘LTS-specials.R’ [0s/1s]
  Running ‘MCD-specials.R’ [0s/1s]
  Comparing ‘MCD-specials.Rout’ to ‘MCD-specials.Rout.save’ ... OK
  Running ‘MT-tst.R’ [4s/4s]
  Running ‘NAcoef.R’ [0s/1s]
  Running ‘OGK-ex.R’ [0s/1s]
  Comparing ‘OGK-ex.Rout’ to ‘OGK-ex.Rout.save’ ... OK
  Running ‘Qn-Sn-plots.R’ [0s/1s]
  Running ‘Rsquared.R’ [1s/1s]
  Comparing ‘Rsquared.Rout’ to ‘Rsquared.Rout.save’ ... OK
  Running ‘binom-ni-small.R’ [0s/1s]
  Comparing ‘binom-ni-small.Rout’ to ‘binom-ni-small.Rout.save’ ... OK
  Running ‘binom-no-x.R’ [0s/0s]
  Running ‘comedian-tst.R’ [0s/1s]
  Running ‘exact-fit-categorical.R’ [0s/0s]
  Running ‘glmrob-1.R’ [5s/5s]
  Running ‘glmrob-specials.R’ [0s/1s]
  Running ‘huber-etc.R’ [0s/0s]
  Comparing ‘huber-etc.Rout’ to ‘huber-etc.Rout.save’ ... OK
  Running ‘large-values.R’ [0s/1s]
  Running ‘lmrob-data.R’ [2s/2s]
  Running ‘lmrob-ex12.R’ [2s/2s]
  Running ‘lmrob-methods.R’ [0s/1s]
  Comparing ‘lmrob-methods.Rout’ to ‘lmrob-methods.Rout.save’ ... OK
  Running ‘lmrob-psifns.R’ [3s/3s]
  Comparing ‘lmrob-psifns.Rout’ to ‘lmrob-psifns.Rout.save’ ... OK
  Running ‘m-s-estimator.R’ [1s/1s]
  Running ‘mc-etc.R’ [1s/1s]
  Running ‘mc-strict.R’ [9s/10s]
  Running ‘nlregrob-tst.R’ [8s/9s]
  Running ‘nlrob-tst.R’ [2s/2s]
  Running ‘poisson-ex.R’ [1s/1s]
  Running ‘psi-rho-etc.R’ [1s/1s]
  Comparing ‘psi-rho-etc.Rout’ to ‘psi-rho-etc.Rout.save’ ... OK
  Running ‘small-sample.R’ [5s/5s]
  Comparing ‘small-sample.Rout’ to ‘small-sample.Rout.save’ ... OK
  Running ‘subsample.R’ [5s/6s]
  Running ‘tlts.R’ [1s/1s]
  Comparing ‘tlts.Rout’ to ‘tlts.Rout.save’ ... OK
  Running ‘tmcd.R’ [4s/5s]
  Running ‘weights.R’ [1s/1s]
  Comparing ‘weights.Rout’ to ‘weights.Rout.save’ ... OK
  Running ‘wgt-himed-xtra.R’ [2s/2s]
  Running ‘wgt-himed.R’ [0s/0s]
  Comparing ‘wgt-himed.Rout’ to ‘wgt-himed.Rout.save’ ... OK
Running the tests in ‘tests/NAcoef.R’ failed.
Complete output:
  > ## test handing of NA coefficients / singular fits
  > ## also check:
  > ## -- what would have to be done if class "lm" was added.
  > ## -- general compatibility to class lm.
  > require(robustbase)
  Loading required package: robustbase
  > options(digits = 5)# -> higher chance of platform independence
  > 
  > ## generate simple example data (almost as in ./weights.R )
  > data <- expand.grid(x1=letters[1:3], x2=LETTERS[1:3], rep=1:3)
  > set.seed(1)
  > data$y <- rnorm(nrow(data))
  > ## drop all combinations of one interaction:
  > data <- subset(data, x1 != 'c' | (x2 != 'B' & x2 != 'C'))
  > ## add collinear variables
  > data$x3 <- rnorm(nrow(data))
  > data$x4 <- rnorm(nrow(data))
  > data$x5 <- data$x3 + data$x4
  > ## add some NA terms
  > data$y[1] <- NA
  > data$x4[2:3] <- NA ## to test anova
  > 
  > ## Classical models start with 'cm', robust just with  'rm' (or just 'm'):
  > cm0 <- lm   (y ~ x1*x2 + x3,	       data)
  > cm1 <- lm   (y ~ x1*x2 + x3 + x4 + x5, data)
  > set.seed(2)
  > rm1 <- lmrob(y ~ x1*x2 + x3 + x4 + x5, data)
  > m3  <- lmrob(y ~ x1*x2 + x3 + x4,      data) # same column space as rm1
  > rm0 <- lmrob(y ~ x1*x2 + x3,	       data)
  > 
  > ## clean version of rm1 (to check predict)
  > data2 <- data.frame(y=data$y[-(1:3)], rm1$x[,!is.na(rm1$coef)])
  > set.seed(2)
  > rm1c <- lmrob(y ~ x1b + x1c + x2B + x2C + x3 + x4 + x1b:x2B + x1b:x2C, data2)
  > 
  > ## add class lm to rm1 (for now)
  > class(rm1) <- c(class(rm1), "lm")
  > class(rm0) <- c(class(rm0), "lm")
  > 
  > ## the full matrix (data) should be returned by model matrix (frame)
  > stopifnot(all.equal(model.matrix(cm1), model.matrix(rm1)),
  +           all.equal(model.frame (cm1), model.frame (rm1)))
  > ## qr decomposition should be for the full data and pivots identical lm result
  > qr.cm1 <- qr(cm1)$qr
  > qr.rm1 <- rm1$qr$qr
  > stopifnot(NCOL(qr.rm1) == NCOL(qr.cm1),
  +           NROW(qr.rm1) == NROW(qr.cm1),
  +           length(rm1$qr$qraux) == length(qr(cm1)$qraux),
  +           all.equal(rm1$qr$pivot, qr(cm1)$pivot),
  +           all.equal(dimnames(qr.rm1),dimnames(qr.cm1)))
  > ## the alias function should return the same result
  > stopifnot(all.equal(alias(cm1), alias(rm1)))
  > 
  > ####
  > ## these helper functions should print NAs for the dropped coefficients
  >   print(rm1)
  
  Call:
  lmrob(formula = y ~ x1 * x2 + x3 + x4 + x5, data = data)
   \--> method = "MM"
  Coefficients:
  (Intercept)          x1b          x1c          x2B          x2C           x3  
       0.4381       0.5968       0.0344       0.2012       0.1789      -0.1320  
           x4           x5      x1b:x2B      x1c:x2B      x1b:x2C      x1c:x2C  
      -0.2155           NA      -1.8763           NA      -0.8651           NA  
  
  > summary(rm1) -> s1
  > confint(rm1) -> ci1
  > stopifnot(identical(is.na(coef(cm1)), apply(ci1, 1L, anyNA)),
  + 	  identical(sigma(rm1),                 s1$ sigma),
  + 	  identical(vcov(rm1, complete=FALSE),  s1$ cov  ),
  + 	  TRUE)
  > 
  > print(s1, showAlgo=FALSE)
  
  Call:
  lmrob(formula = y ~ x1 * x2 + x3 + x4 + x5, data = data)
   \--> method = "MM"
  Residuals:
      Min      1Q  Median      3Q     Max 
  -1.4584 -0.3556  0.0246  0.3651  1.0296 
  
  Coefficients: (3 not defined because of singularities)
              Estimate Std. Error t value Pr(>|t|)
  (Intercept)   0.4381     0.5443    0.80     0.44
  x1b           0.5968     0.6423    0.93     0.38
  x1c           0.0344     0.6880    0.05     0.96
  x2B           0.2012     0.7164    0.28     0.79
  x2C           0.1789     0.6871    0.26     0.80
  x3           -0.1320     0.4155   -0.32     0.76
  x4           -0.2155     0.1694   -1.27     0.24
  x5                NA         NA      NA       NA
  x1b:x2B      -1.8763     1.2153   -1.54     0.16
  x1c:x2B           NA         NA      NA       NA
  x1b:x2C      -0.8651     0.7466   -1.16     0.28
  x1c:x2C           NA         NA      NA       NA
  
  Robust residual standard error: 0.927 
    (3 observations deleted due to missingness)
  Multiple R-squared:  0.338,	Adjusted R-squared:  -0.251 
  Convergence in 15 IRWLS iterations
  
  Robustness weights: 
   2 weights are ~= 1. The remaining 16 ones are summarized as
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    0.787   0.937   0.985   0.952   0.988   0.994 
  > ci1
                 2.5 %  97.5 %
  (Intercept) -0.79333 1.66946
  x1b         -0.85607 2.04973
  x1c         -1.52188 1.59076
  x2B         -1.41948 1.82189
  x2C         -1.37549 1.73320
  x3          -1.07182 0.80783
  x4          -0.59863 0.16756
  x5                NA      NA
  x1b:x2B     -4.62539 0.87283
  x1c:x2B           NA      NA
  x1b:x2C     -2.55391 0.82381
  x1c:x2C           NA      NA
  > ## drop1 should return df = 0
  > #drop1(rm1) ## drop.lm does not return valid results (yet)!
  > 
  > ####
  > ## methods that should just drop the NA coefficients
  > ## m3 is actually the same as rm1, so anova should raise an error
  > tools::assertError(anova(rm1, m3, test="Wald"))
  > tools::assertError(anova(rm1, m3, test="Deviance"))
  > ## but comparing rm1 and rm0 should be ok
  > anova(rm1, rm0, test="Wald")
  Robust Wald Test Table
  
  Model 1: y ~ x1 * x2 + x3 + x4 + x5
  Model 2: y ~ x1 * x2 + x3
  Largest model fitted by lmrob(), i.e. SM
  
    pseudoDf Test.Stat Df Pr(>chisq)
  1        6                        
  2       10      1.62  1        0.2
  > anova(rm1, rm0, test="Deviance")
  Robust Deviance Table
  
  Model 1: y ~ x1 * x2 + x3 + x4 + x5
  Model 2: y ~ x1 * x2 + x3
  Largest model fitted by lmrob(), i.e. SM
  
    pseudoDf Test.Stat Df Pr(>chisq)
  1        6                        
  2       10       1.4  1       0.24
  > ## commands with single #:
  > ## they do (or might) not return sensible results for robust fits
  > ## and need to be checked again
  > #cooks.distance(rm1)
  > #deviance(rm1)
  > #dfbeta(rm1)
  > #dfbetas(rm1)
  > #effects(rm1) ## fails
  > #extractAIC(rm1)
  > #influence(rm1)
  > stopifnot(all.equal(hv1 <- hatvalues(rm1), .lmrob.hat(wqr=rm1$qr), tol=1e-15),
  +           all.equal(hv1, stats:::hatvalues.lm(rm1), tol=1e-15),
  +           all.equal(hat(cm1$qr), unname(hatvalues(cm1)), tol=1e-15),
  +           all.equal(unname(hv1), hat(rm1$qr), tol=1e-15),
  +           ## ditto :
  +           all.equal(hv1c <- hatvalues(rm1c), stats:::hatvalues.lm(rm1c), tol=1e-15))
  Error in match.arg(type) : 'arg' should be one of "prior", "robustness"
  Calls: stopifnot ... weighted.residuals -> weights -> weights.lmrob -> match.arg
  Execution halted