Running 'bic-too.R' [0s]
  Comparing 'bic-too.Rout' to 'bic-too.Rout.save' ... OK
  Running 'bic.R' [0s]
  Comparing 'bic.Rout' to 'bic.Rout.save' ... OK
  Running 'foo.R' [158s]
  Running 'goo.R' [5s]
  Comparing 'goo.Rout' to 'goo.Rout.save' ... OK
  Running 'graph.R' [158s]
  Running 'soo.R' [175s]
Running the tests in 'tests/foo.R' failed.
Complete output:
  > 
  >  library(glmbb)
  >  data(crabs)
  > 
  >  gout <- glm(satell ~ color * spine * width * weight, family = poisson,
  +      data = crabs)
  >  sum(! is.na(gout$coefficients))
  [1] 36
  >  gout <- glm(satell ~ 1, family = poisson, data = crabs)
  >  sum(! is.na(gout$coefficients))
  [1] 1
  > 
  >  # default criterion AIC
  > 
  >  gout <- glmbb(satell ~ color * spine * width * weight, data = crabs)
  Warning messages:
  1: glm.fit: fitted rates numerically 0 occurred 
  2: glm.fit: fitted rates numerically 0 occurred 
  3: glm.fit: fitted rates numerically 0 occurred 
  4: glm.fit: fitted rates numerically 0 occurred 
  5: glm.fit: fitted rates numerically 0 occurred 
  > 
  >  fits <- ls(envir = gout$envir, pattern = "^sha1")
  >  length(fits)
  [1] 141
  >  criteria <- Map(function(x) get(x, envir = gout$envir)$criterion, fits)
  >  formulae <- Map(function(x) get(x, envir = gout$envir)$formula, fits)
  >  names(criteria) <- NULL
  >  names(formulae) <- NULL
  >  criteria <- unlist(criteria)
  >  formulae <- sapply(formulae, tidy.formula.hierarchical)
  >  fred <- data.frame(criteria, formulae, stringsAsFactors = FALSE)
  >  fred <- fred[order(criteria), ]
  >  fred <- fred[fred$criteria <= min(fred$criteria) + gout$cutoff, ]
  >  w <- fred$criteria
  >  w <- w - w[1]
  >  w <- exp(- w / 2)
  >  w <- w / sum(w)
  >  fred <- data.frame(criterion = fred$criteria, weight = w,
  +      formula = fred$formulae, stringsAsFactors = FALSE)
  >  opt <- options(width = 132)
  >  print(fred, right = FALSE, row.names = FALSE, print.gap = 2)
    criterion  weight        formula                                                                                  
    894.3717   0.1453384985  satell ~ color*spine*width + spine*width*weight                                          
    895.5158   0.0820222126  satell ~ color*spine*width + color*width*weight + spine*width*weight                     
    895.8019   0.0710914889  satell ~ color*spine + color*width + width*weight                                        
    896.3546   0.0539256048  satell ~ color*spine + spine*weight                                                      
    896.8069   0.0430104842  satell ~ color*spine + color*width*weight                                                
    896.8724   0.0416253123  satell ~ color*spine*width + color*spine*weight + color*width*weight                     
    896.9920   0.0392086644  satell ~ color*spine + width*weight                                                      
    897.0421   0.0382400308  satell ~ color*spine + spine*width + width*weight                                        
    897.2368   0.0346914597  satell ~ color*spine + spine*weight + width*weight                                       
    897.3034   0.0335554255  satell ~ color*spine + color*width + spine*weight + width*weight                         
    897.4383   0.0313678836  satell ~ width + color*spine + spine*weight                                              
    897.4502   0.0311809683  satell ~ color*spine + color*width + spine*weight                                        
    897.7957   0.0262344918  satell ~ color*spine + color*weight + width*weight                                       
    898.1885   0.0215559653  satell ~ color*spine + spine*weight + color*width*weight                                 
    898.4414   0.0189955058  satell ~ color*spine + color*width + spine*width + width*weight                          
    898.6678   0.0169626590  satell ~ weight + color*spine + spine*width                                              
    899.0153   0.0142572951  satell ~ color*spine + color*weight + spine*weight                                       
    899.0550   0.0139768096  satell ~ color*weight + color*spine*width + spine*width*weight                           
    899.2803   0.0124878264  satell ~ color*spine + spine*width + spine*weight + width*weight                         
    899.3480   0.0120724198  satell ~ color*spine*width + color*spine*weight + color*width*weight + spine*width*weight
    899.6955   0.0101466201  satell ~ width*weight + color*spine*width                                                
    899.7204   0.0100212858  satell ~ color*spine + spine*width + color*width*weight                                  
    899.7413   0.0099169483  satell ~ color*spine + color*weight + spine*weight + width*weight                        
    899.7599   0.0098253181  satell ~ color*spine*weight + color*width*weight                                         
    899.8308   0.0094829004  satell ~ color*spine + spine*width + color*weight + width*weight                         
    899.8451   0.0094154788  satell ~ color*spine*weight                                                              
    899.9891   0.0087612952  satell ~ color*spine + spine*width + spine*weight                                        
    900.0586   0.0084622489  satell ~ weight + color*spine + color*width + spine*width                                
    900.1454   0.0081028189  satell ~ color*spine*width + color*spine*weight                                          
    900.1722   0.0079951320  satell ~ color*spine + color*width + spine*width + spine*weight                          
    900.2131   0.0078329882  satell ~ width + color*spine + color*weight + spine*weight                               
    900.2194   0.0078084370  satell ~ color*spine + color*width + spine*width + spine*weight + width*weight           
    900.3814   0.0072010266  satell ~ weight + color*spine + color*width                                              
    900.4542   0.0069436636  satell ~ color*spine + color*weight                                                      
    900.5091   0.0067554243  satell ~ width*weight + color*spine*width + color*spine*weight                           
    900.6301   0.0063588720  satell ~ color*spine + spine*width + spine*weight + color*width*weight                   
    900.6349   0.0063435477  satell ~ spine*weight + width*weight + color*spine*width                                 
    900.6811   0.0061989923  satell ~ color*spine*width + color*width*weight                                          
    900.7588   0.0059625429  satell ~ color*spine + color*width + color*weight + width*weight                         
    901.1290   0.0049550396  satell ~ color*spine + spine*width + color*weight                                        
    901.1794   0.0048316864  satell ~ width + color*spine*weight                                                      
    901.2306   0.0047097195  satell ~ spine*weight + color*spine*width                                                
    901.3461   0.0044453470  satell ~ width*weight + color*spine*weight                                               
    901.3480   0.0044411947  satell ~ color*spine*width*weight                                                        
    901.3955   0.0043369183  satell ~ spine*weight + color*spine*width + color*width*weight                           
    901.4959   0.0041245641  satell ~ color*spine + spine*width + color*weight + spine*weight + width*weight          
    902.1856   0.0029215329  satell ~ width + color*spine + color*weight                                              
    902.3045   0.0027529309  satell ~ weight + color*spine*width                                                      
    902.3989   0.0026259610  satell ~ color*spine + spine*width + color*weight + spine*weight                         
    902.6540   0.0023115121  satell ~ color*spine + color*width + color*weight + spine*weight                         
    902.6887   0.0022718034  satell ~ color*spine + color*width + color*weight + spine*weight + width*weight          
    902.7721   0.0021790082  satell ~ spine*width + color*spine*weight + color*width*weight                           
    902.9429   0.0020006266  satell ~ color*spine + spine*width*weight                                                
    902.9670   0.0019766797  satell ~ color*spine*width + color*spine*weight + spine*width*weight                     
    902.9771   0.0019667565  satell ~ color*width + color*spine*weight                                                
    903.4752   0.0015331632  satell ~ spine*width + width*weight + color*spine*weight                                 
    903.5396   0.0014845317  satell ~ color*spine + color*width + spine*width + color*weight + width*weight           
    903.5439   0.0014813705  satell ~ color*width*weight                                                              
    903.6404   0.0014115838  satell ~ color*width + width*weight + color*spine*weight                                 
    903.7620   0.0013283298  satell ~ color*spine + color*width + spine*width*weight                                  
    903.9146   0.0012307232  satell ~ weight + color*spine                                                            
    903.9880   0.0011863706  satell ~ spine*width + color*spine*weight                                                
    904.0089   0.0011740501  satell ~ color*spine + color*width + color*weight                                        
    904.3661   0.0009820488  satell ~ spine + color*width*weight                                                      
  >  options(opt)
  > 
  >  # check criteria
  >  criteria.too <- Map(function(x) get(x, envir = gout$envir)$aic, fits)
  >  names(criteria.too) <- NULL
  >  criteria.too <- unlist(criteria.too)
  >  identical(criteria, criteria.too)
  [1] TRUE
  > 
  >  # check we do indeed have all less than cutoff
  > 
  >  gout.full <- glmbb(satell ~ color * spine * width * weight,
  +      data = crabs, cutoff = Inf)
  Warning messages:
  1: glm.fit: fitted rates numerically 0 occurred 
  2: glm.fit: fitted rates numerically 0 occurred 
  3: glm.fit: fitted rates numerically 0 occurred 
  4: glm.fit: fitted rates numerically 0 occurred 
  5: glm.fit: fitted rates numerically 0 occurred 
  > 
  >  fits <- ls(envir = gout$envir, pattern = "^sha1")
  >  criteria <- Map(function(x) get(x, envir = gout$envir)$criterion, fits)
  >  criteria <- unlist(criteria)
  >  fits.full <- ls(envir = gout.full$envir, pattern = "^sha1")
  >  criteria.full <- Map(function(x)
  +      get(x, envir = gout.full$envir)$criterion, fits)
  >  criteria.full <- unlist(criteria.full)
  >  length(fits)
  [1] 141
  >  length(fits.full)
  [1] 167
  >  all.equal(min(criteria), min(criteria.full))
  [1] TRUE
  >  inies <- which(criteria.full <= min(criteria.full) + gout$cutoff)
  >  idx <- match(names(criteria.full)[inies], names(criteria))
  >  all(! is.na(idx))
  [1] TRUE
  >  all.equal(criteria.full[inies], criteria[idx])
  [1] TRUE
  > 
  >  # now BIC
  > 
  >  gout <- glmbb(satell ~ color * spine * width * weight,
  +      family = poisson, data = crabs, criterion = "BIC")
  Warning message:
  glm.fit: fitted rates numerically 0 occurred 
  > 
  >  fits <- ls(envir = gout$envir, pattern = "^sha1")
  >  length(fits)
  [1] 135
  >  criteria <- Map(function(x) get(x, envir = gout$envir)$criterion, fits)
  >  formulae <- Map(function(x) get(x, envir = gout$envir)$formula, fits)
  >  names(criteria) <- NULL
  >  names(formulae) <- NULL
  >  criteria <- unlist(criteria)
  >  formulae <- sapply(formulae, tidy.formula.hierarchical)
  >  fred <- data.frame(criteria, formulae, stringsAsFactors = FALSE)
  >  fred <- fred[order(criteria), ]
  >  fred <- fred[fred$criteria <= min(fred$criteria) + gout$cutoff, ]
  >  w <- fred$criteria
  >  w <- w - w[1]
  >  w <- exp(- w / 2)
  >  w <- w / sum(w)
  >  fred <- data.frame(criterion = fred$criteria, weight = w,
  +      formula = fred$formulae, stringsAsFactors = FALSE)
  >  print(fred, right = FALSE, row.names = FALSE, print.gap = 2)
    criterion  weight       formula                      
    921.2009   0.902697702  satell ~ width*weight        
    926.4707   0.064746887  satell ~ weight              
    929.5306   0.014020638  satell ~ color + width*weight
    930.0982   0.010556291  satell ~ spine + width*weight
    930.6581   0.007978481  satell ~ width + weight      
  > 
  >  # check criteria
  >  criteria.too <- Map(function(x) BIC(get(x, envir = gout$envir)), fits)
  >  names(criteria.too) <- NULL
  >  criteria.too <- unlist(criteria.too)
  >  identical(criteria, criteria.too)
  [1] TRUE
  > 
  >  # now AICc
  > 
  >  gout <- glmbb(satell ~ color * spine * width * weight,
  +      family = poisson, data = crabs, criterion = "AICc", cutoff = 5)
  Warning messages:
  1: glm.fit: fitted rates numerically 0 occurred 
  2: glm.fit: fitted rates numerically 0 occurred 
  3: glm.fit: fitted rates numerically 0 occurred 
  4: glm.fit: fitted rates numerically 0 occurred 
  >  fits <- ls(envir = gout$envir, pattern = "^sha1")
  >  criteria <- Map(function(x) get(x, envir = gout$envir)$criterion, fits)
  >  criteria.too <- Map(function(x) get(x, envir = gout$envir)$aic, fits)
  >  p.too <- Map(function(x)
  +      sum(! is.na(get(x, envir = gout$envir)$coefficients)), fits)
  >  n <- nrow(crabs)
  >  criteria.too <- Map(function(x, p) x + 2 * p * (p + 1) / (n - p - 1),
  +      criteria.too, p.too)
  >  all.equal(criteria, criteria.too)
  [1] TRUE
  > 
  >  opt <- options(width = 132)
  >  summary(gout)
  
  Results of search for hierarchical models with lowest AICc.
  Search was for all models with AICc no larger than min(AICc) + 5
  These are shown below.
  
    criterion  weight   formula                                                         
    899.4      0.19469  satell ~ color*spine + spine*weight                             
    900.0      0.14155  satell ~ color*spine + width*weight                             
    900.2      0.12846  satell ~ color*spine + color*width + width*weight               
    900.9      0.09134  satell ~ width + color*spine + spine*weight                     
    901.0      0.08842  satell ~ color*spine + spine*width + width*weight               
    901.2      0.08022  satell ~ color*spine + spine*weight + width*weight              
    902.2      0.04940  satell ~ weight + color*spine + spine*width                     
    902.2      0.04741  satell ~ color*spine + color*weight + width*weight              
    902.4      0.04332  satell ~ color*spine + color*width + spine*weight               
    902.8      0.03525  satell ~ color*spine + color*width + spine*weight + width*weight
    903.5      0.02576  satell ~ color*spine + color*weight + spine*weight              
    903.9      0.02022  satell ~ color*spine + color*weight                             
    904.0      0.01996  satell ~ color*spine + color*width + spine*width + width*weight 
    904.2      0.01735  satell ~ color*spine + spine*width + spine*weight + width*weight
    904.3      0.01665  satell ~ weight + color*spine + color*width                     
  
  >  summary(gout, cutoff = 2)
  
  Results of search for hierarchical models with lowest AICc.
  Search was for all models with AICc no larger than min(AICc) + 5
  Summary was requested for all models with AICc no larger than min(AICc) + 2
  Since summary cutoff < search cutoff, weights do not sum to one
  
    criterion  weight  formula                                           
    899.4      0.2686  satell ~ color*spine + spine*weight               
    900.0      0.1953  satell ~ color*spine + width*weight               
    900.2      0.1773  satell ~ color*spine + color*width + width*weight 
    900.9      0.1260  satell ~ width + color*spine + spine*weight       
    901.0      0.1220  satell ~ color*spine + spine*width + width*weight 
    901.2      0.1107  satell ~ color*spine + spine*weight + width*weight
  
  >  summary(gout, cutoff = 8)
  
  Results of search for hierarchical models with lowest AICc.
  Search was for all models with AICc no larger than min(AICc) + 5
  Summary was requested for all models with AICc no larger than min(AICc) + 8
  Since the summary cutoff > search cutoff, some models
       with AICc below the summary cutoff may have been missed
  
    criterion  weight    formula                                                                       
    899.4      0.171411  satell ~ color*spine + spine*weight                                           
    900.0      0.124631  satell ~ color*spine + width*weight                                           
    900.2      0.113104  satell ~ color*spine + color*width + width*weight                             
    900.9      0.080424  satell ~ width + color*spine + spine*weight                                   
    901.0      0.077852  satell ~ color*spine + spine*width + width*weight                             
    901.2      0.070628  satell ~ color*spine + spine*weight + width*weight                            
    902.2      0.043491  satell ~ weight + color*spine + spine*width                                   
    902.2      0.041738  satell ~ color*spine + color*weight + width*weight                            
    902.4      0.038140  satell ~ color*spine + color*width + spine*weight                             
    902.8      0.031036  satell ~ color*spine + color*width + spine*weight + width*weight              
    903.5      0.022683  satell ~ color*spine + color*weight + spine*weight                            
    903.9      0.017803  satell ~ color*spine + color*weight                                           
    904.0      0.017569  satell ~ color*spine + color*width + spine*width + width*weight               
    904.2      0.015275  satell ~ color*spine + spine*width + spine*weight + width*weight              
    904.3      0.014660  satell ~ weight + color*spine + color*width                                   
    904.4      0.013939  satell ~ color*spine + spine*width + spine*weight                             
    904.8      0.011593  satell ~ color*spine*width + spine*width*weight                               
    904.9      0.010941  satell ~ color*spine + color*width*weight                                     
    905.0      0.010351  satell ~ weight + color*spine + color*width + spine*width                     
    905.2      0.009581  satell ~ width + color*spine + color*weight + spine*weight                    
    905.3      0.009172  satell ~ color*spine + color*weight + spine*weight + width*weight             
    905.4      0.008771  satell ~ color*spine + spine*width + color*weight + width*weight              
    906.0      0.006475  satell ~ color*spine*weight                                                   
    906.1      0.006061  satell ~ color*spine + spine*width + color*weight                             
    906.1      0.005948  satell ~ width + color*spine + color*weight                                   
    906.2      0.005743  satell ~ weight + color*spine                                                 
    906.3      0.005498  satell ~ color*spine + color*width + spine*width + spine*weight               
    906.9      0.004100  satell ~ color*spine + color*width + color*weight + width*weight              
    907.0      0.003924  satell ~ color*spine + color*width + spine*width + spine*weight + width*weight
    907.0      0.003798  satell ~ color*width*weight                                                   
    907.1      0.003660  satell ~ width*weight + color*spine*width                                     
  
  > 
  > 
  > proc.time()
     user  system elapsed 
     6.46    0.17    6.64 
Running the tests in 'tests/graph.R' failed.
Complete output:
  > 
  >  library(glmbb)
  >  data(crabs)
  > 
  >  gout <- glmbb(satell ~ color * spine * width * weight,
  +      data = crabs, cutoff = Inf)
  Warning messages:
  1: glm.fit: fitted rates numerically 0 occurred 
  2: glm.fit: fitted rates numerically 0 occurred 
  3: glm.fit: fitted rates numerically 0 occurred 
  4: glm.fit: fitted rates numerically 0 occurred 
  5: glm.fit: fitted rates numerically 0 occurred 
  > 
  >  fits <- ls(envir = gout$envir, pattern = "^sha1")
  > 
  >  form1 <- Map(function (x) get(x, envir = gout$envir)$formula, fits)
  > 
  >  form2 <- sapply(form1, tidy.formula.hierarchical)
  >  names(form2) <- NULL
  > 
  >  foo <- Vectorize(function(x) isHierarchical(as.formula(x)))
  >  all(foo(form2))
  [1] TRUE
  > 
  >  library(digest)
  > 
  >  digest.interaction.graph <- function(formula) {
  +     stopifnot(inherits(formula, "formula"))
  +     mt <- terms(formula)
  +     mf <- attr(mt, "factors")
  +     if (! is.matrix(mf)) {
  +         g <- "empty graph"
  +     } else {
  +         mr <- attr(mt, "response")
  +         if (mr != 0)
  +             mf <- mf[- mr, , drop = FALSE]
  +         g <- matrix(0, nrow(mf), nrow(mf))
  +         for (i in 1:nrow(mf))
  +             for (j in 1:nrow(mf))
  +                 if (i != j)
  +                     g[i, j] <- any(mf[i, ] * mf[j, ] >= 1)
  +         dimnames(g) <- list(rownames(mf), rownames(mf))
  +         idx <- match(sort(rownames(mf)), rownames(mf))
  +         g <- g[idx, , drop = FALSE]
  +         g <- g[ , idx, drop = FALSE]
  +     }
  +     digest(g, algo = "sha1")
  +  }
  > 
  >  nterms <- function(formula) {
  +     stopifnot(inherits(formula, "formula"))
  +     mt <- terms(formula)
  +     ml <- attr(mt, "term.labels")
  +     length(ml)
  +  }
  > 
  >  foo <- Vectorize(function(x) isGraphical(as.formula(x)))
  >  is.graphical.1 <- foo(form2)
  > 
  >  foo <- Vectorize(function(x) digest.interaction.graph(as.formula(x)))
  >  graphs <- foo(form2)
  >  fred <- split(form2, graphs)
  >  foo <- Vectorize(function(x) nterms(as.formula(x)))
  >  fred.max <- sapply(fred, function(x) x[foo(x) == max(foo(x))])
  >  is.graphical.2 <- form2 %in% fred.max
  >  all(is.graphical.1 == is.graphical.2)
  [1] TRUE
  > 
  > 
  > proc.time()
     user  system elapsed 
     2.70    0.26    2.90 
Running the tests in 'tests/soo.R' failed.
Complete output:
  > 
  >  library(digest)
  >  library(glmbb)
  > 
  >  foo <- terms(~ Contact * Influence * Housing + Satisfaction)
  >  bar <- attr(foo, "term.labels")
  >  baz <- glmbb:::standardize.term.labels(bar)
  > 
  >  foo <- terms(~ Satisfaction + Contact * Influence * Housing)
  >  bar <- attr(foo, "term.labels")
  >  qux <- glmbb:::standardize.term.labels(bar)
  > 
  >  ! identical(baz, qux)
  [1] TRUE
  >  identical(sort(baz), sort(qux))
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.23    0.01    0.23