13  add_dummy_ from node1,function


The examples in Chapter 13 require (see the explanation of the function name conflict in Section 7.4)

library(maxEff)
# Loading required package: groupedHyperframe
# Registered S3 method overwritten by 'pROC':
#   method   from            
#   plot.roc spatstat.explore
search path & loadedNamespaces on author’s computer
search()
#  [1] ".GlobalEnv"                "package:maxEff"            "package:groupedHyperframe" "package:stats"             "package:graphics"          "package:grDevices"         "package:utils"            
#  [8] "package:datasets"          "package:methods"           "Autoloads"                 "package:base"
loadedNamespaces() |> sort.int()
#   [1] "abind"             "base"              "caret"             "class"             "cli"               "cluster"           "codetools"         "compiler"          "data.table"       
#  [10] "datasets"          "deldir"            "digest"            "doParallel"        "dplyr"             "evaluate"          "farver"            "fastmap"           "fastmatrix"       
#  [19] "foreach"           "future"            "future.apply"      "generics"          "geomtextpath"      "GET"               "ggplot2"           "globals"           "glue"             
#  [28] "goftest"           "gower"             "graphics"          "grDevices"         "grid"              "gridExtra"         "groupedHyperframe" "gtable"            "hardhat"          
#  [37] "htmltools"         "htmlwidgets"       "ipred"             "iterators"         "jsonlite"          "knitr"             "lattice"           "lava"              "lifecycle"        
#  [46] "listenv"           "lubridate"         "magrittr"          "MASS"              "Matrix"            "matrixStats"       "maxEff"            "methods"           "ModelMetrics"     
#  [55] "nlme"              "nnet"              "otel"              "parallel"          "parallelly"        "patchwork"         "pillar"            "pkgconfig"         "plyr"             
#  [64] "polyclip"          "pracma"            "pROC"              "prodlim"           "purrr"             "R6"                "RColorBrewer"      "Rcpp"              "recipes"          
#  [73] "reshape2"          "rlang"             "rmarkdown"         "rpart"             "rstudioapi"        "S7"                "scales"            "SpatialPack"       "spatstat.data"    
#  [82] "spatstat.explore"  "spatstat.geom"     "spatstat.random"   "spatstat.sparse"   "spatstat.univar"   "spatstat.utils"    "splines"           "stats"             "stats4"           
#  [91] "stringi"           "stringr"           "survival"          "systemfonts"       "tensor"            "textshaping"       "tibble"            "tidyselect"        "timechange"       
# [100] "timeDate"          "tools"             "utils"             "vctrs"             "viridisLite"       "withr"             "xfun"              "yaml"

🚧 Chapter 13 is being re-written English-wise. All code are correct here, though. Expected delivery by 2025-12-31.

The internal class 'add_dummy_' defined in package maxEff v0.2.1 inherits from the class 'node1' (Chapter 32), with additional attributes

The S3 method base::print.default() displays each 'add_dummy_' object.

Example: training models b0 in training set s0: 1st element
b0[[1L]]
Example: training models b0 in training set s0: 2nd element
b0[[2L]]
Example: training models c0 in test-subset of training set s0: 1st element
c0[[1L]]
Example: training models c0 in test-subset of training set s0: 2nd element
c0[[2L]]

The S3 method predict.node1() evaluates a dichotomizing rule in a hyper data frame. Note that user must call the S3 method predict.node1() explicitly, otherwise the S3 generic stats::predict() would dispatch to predict.add_dummy_().

Example: predict.node1(); 1st selected logical predictor
b0[[1L]] |> 
  predict.node1(newdata = s0) |>
  table() |> 
  addmargins()  
b0[[1L]] |> 
  predict.node1(newdata = s1) |>
  table() |> 
  addmargins()
Example: predict.node1(); 2nd selected logical predictor
b0[[2L]] |> 
  predict.node1(newdata = s0) |>
  table() |> 
  addmargins() 
b0[[2L]] |> 
  predict.node1(newdata = s1) |>
  table() |> 
  addmargins()  
Example: predict.node1(); 1st selected logical predictor via repeated partitions
c0[[1L]] |>
  predict.node1(newdata = s0) |>
  table() |> 
  addmargins()
c0[[1L]] |>
  predict.node1(newdata = s1) |>
  table() |> 
  addmargins()
Example: predict.node1(); 2nd selected logical predictor via repeated partitions
c0[[2L]] |>
  predict.node1(newdata = s0) |>
  table() |> 
  addmargins()
c0[[2L]] |>
  predict.node1(newdata = s1) |>
  table() |> 
  addmargins()

The S3 method predict.add_dummy_() is the workhorse of the S3 method predict.add_dummy().

Example: predict.add_dummy_(); predicted models b1: 1st element
b0[[1L]] |> 
  predict(newdata = s1) |>
  identical(y = b1[[1L]]) |>
  stopifnot()
Example: predict.add_dummy_(); predicted models b1: 2nd element
b0[[2L]] |> 
  predict(newdata = s1) |>
  identical(y = b1[[2L]]) |>
  stopifnot()
Example: predict.add_dummy_(); predicted models c1: 1st element
c0[[1L]] |> 
  predict(newdata = s1) |>
  identical(y = c1[[1L]]) |>
  stopifnot()
Example: predict.add_dummy_(); predicted models c1: 2nd element
c0[[2L]] |> 
  predict(newdata = s1) |>
  identical(y = c1[[2L]]) |>
  stopifnot()