This function discretizes a user-provided test dataset given a discretization scheme provided by an S4 glmdisc object. It then applies the learnt logistic regression model and outputs its prediction (see predict.glm).

This defines the method "discretize" which will discretize a new input dataset given a discretization scheme of S4 class glmdisc

discretize(object, data)

# S4 method for glmdisc
discretize(object, data)

Arguments

object

glmdisc object

data

the data to discretize according to the provided discretization scheme

Author

Adrien Ehrhardt.

Examples

# Simulation of a discretized logit model set.seed(1) x <- matrix(runif(300), nrow = 100, ncol = 3) cuts <- seq(0, 1, length.out = 4) xd <- apply(x, 2, function(col) as.numeric(cut(col, cuts))) theta <- t(matrix(c(0, 0, 0, 2, 2, 2, -2, -2, -2), ncol = 3, nrow = 3)) log_odd <- rowSums(t(sapply(seq_along(xd[, 1]), function(row_id) { sapply( seq_along(xd[row_id, ]), function(element) theta[xd[row_id, element], element] ) }))) y <- rbinom(100, 1, 1 / (1 + exp(-log_odd))) sem_disc <- glmdisc(x, y, iter = 50, m_start = 4, test = FALSE, validation = FALSE, criterion = "aic" ) discretize(sem_disc, data.frame(x))
#> [,1] [,2] [,3] #> [1,] "1" "4" "1" #> [2,] "1" "3" "1" #> [3,] "4" "3" "1" #> [4,] "3" "4" "1" #> [5,] "1" "4" "1" #> [6,] "3" "3" "1" #> [7,] "3" "3" "1" #> [8,] "4" "4" "3" #> [9,] "4" "4" "1" #> [10,] "1" "4" "1" #> [11,] "1" "4" "1" #> [12,] "1" "4" "3" #> [13,] "4" "3" "1" #> [14,] "1" "4" "1" #> [15,] "3" "3" "1" #> [16,] "2" "3" "1" #> [17,] "4" "4" "1" #> [18,] "3" "3" "1" #> [19,] "1" "4" "1" #> [20,] "3" "4" "1" #> [21,] "3" "4" "1" #> [22,] "1" "4" "1" #> [23,] "4" "4" "1" #> [24,] "1" "3" "1" #> [25,] "1" "4" "1" #> [26,] "1" "4" "1" #> [27,] "1" "4" "1" #> [28,] "1" "3" "3" #> [29,] "3" "3" "1" #> [30,] "1" "4" "1" #> [31,] "2" "4" "1" #> [32,] "4" "3" "3" #> [33,] "2" "3" "1" #> [34,] "1" "4" "1" #> [35,] "3" "4" "1" #> [36,] "4" "4" "1" #> [37,] "3" "4" "1" #> [38,] "1" "4" "1" #> [39,] "4" "4" "1" #> [40,] "1" "4" "1" #> [41,] "3" "4" "1" #> [42,] "4" "4" "1" #> [43,] "3" "3" "1" #> [44,] "2" "3" "1" #> [45,] "2" "4" "1" #> [46,] "3" "4" "1" #> [47,] "1" "3" "1" #> [48,] "2" "4" "3" #> [49,] "4" "3" "1" #> [50,] "4" "4" "1" #> [51,] "2" "4" "1" #> [52,] "3" "4" "1" #> [53,] "2" "3" "1" #> [54,] "1" "4" "1" #> [55,] "1" "4" "1" #> [56,] "1" "3" "3" #> [57,] "1" "4" "1" #> [58,] "2" "3" "1" #> [59,] "4" "3" "1" #> [60,] "1" "3" "1" #> [61,] "3" "3" "1" #> [62,] "1" "4" "1" #> [63,] "2" "4" "1" #> [64,] "1" "4" "1" #> [65,] "4" "4" "1" #> [66,] "1" "4" "1" #> [67,] "2" "3" "3" #> [68,] "4" "3" "1" #> [69,] "1" "4" "1" #> [70,] "3" "3" "1" #> [71,] "1" "4" "3" #> [72,] "3" "4" "3" #> [73,] "1" "4" "1" #> [74,] "1" "4" "1" #> [75,] "2" "4" "1" #> [76,] "3" "4" "1" #> [77,] "3" "4" "1" #> [78,] "1" "4" "1" #> [79,] "3" "4" "1" #> [80,] "3" "4" "1" #> [81,] "2" "3" "3" #> [82,] "4" "3" "1" #> [83,] "1" "4" "1" #> [84,] "1" "4" "1" #> [85,] "4" "4" "3" #> [86,] "1" "3" "1" #> [87,] "4" "4" "1" #> [88,] "1" "4" "1" #> [89,] "1" "4" "3" #> [90,] "1" "4" "1" #> [91,] "1" "4" "1" #> [92,] "1" "4" "3" #> [93,] "4" "3" "1" #> [94,] "3" "4" "1" #> [95,] "3" "3" "1" #> [96,] "3" "4" "1" #> [97,] "2" "3" "3" #> [98,] "1" "4" "3" #> [99,] "3" "3" "3" #> [100,] "4" "4" "1"