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

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

predict(object, ...)

predict.glmdisc(object, predictors)

# S4 method for glmdisc
predict(object, predictors)

Arguments

object

The S4 discretization object.

...

Essai

predictors

The test dataframe to discretize and for which we wish to have predictions.

Details

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 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).

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" ) predict(sem_disc, data.frame(x))
#> [1] 6.090519e-01 4.675521e-01 5.877959e-01 2.143074e-01 6.090519e-01 #> [6] 1.111129e-01 1.111129e-01 5.573432e-01 1.885641e-01 6.090519e-01 #> [11] 6.090519e-01 4.675743e-01 5.877959e-01 6.090519e-01 1.111129e-01 #> [16] 1.000000e+00 1.885641e-01 1.111129e-01 6.090519e-01 2.143074e-01 #> [21] 2.143074e-01 6.090519e-01 1.885641e-01 4.675521e-01 6.090519e-01 #> [26] 6.090519e-01 6.090519e-01 3.311058e-01 1.111129e-01 6.090519e-01 #> [31] 1.000000e+00 8.854023e-01 1.000000e+00 6.090519e-01 2.143074e-01 #> [36] 1.885641e-01 2.143074e-01 6.090519e-01 1.885641e-01 6.090519e-01 #> [41] 2.143074e-01 1.885641e-01 1.111129e-01 1.000000e+00 1.000000e+00 #> [46] 2.143074e-01 4.675521e-01 4.359464e-07 5.877959e-01 1.885641e-01 #> [51] 1.000000e+00 2.143074e-01 1.000000e+00 6.090519e-01 6.090519e-01 #> [56] 3.311058e-01 6.090519e-01 1.000000e+00 5.877959e-01 4.675521e-01 #> [61] 1.111129e-01 6.090519e-01 1.000000e+00 6.090519e-01 1.885641e-01 #> [66] 6.090519e-01 1.000000e+00 5.877959e-01 6.090519e-01 1.111129e-01 #> [71] 4.675743e-01 1.730525e-11 6.090519e-01 6.090519e-01 1.000000e+00 #> [76] 2.143074e-01 2.143074e-01 6.090519e-01 2.143074e-01 2.143074e-01 #> [81] 1.000000e+00 5.877959e-01 6.090519e-01 6.090519e-01 5.573432e-01 #> [86] 4.675521e-01 1.885641e-01 6.090519e-01 4.675743e-01 6.090519e-01 #> [91] 6.090519e-01 4.675743e-01 5.877959e-01 2.143074e-01 1.111129e-01 #> [96] 2.143074e-01 1.000000e+00 4.675743e-01 7.930697e-12 1.885641e-01