Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


shapr (version 0.2.2)

create_ctree: Make all conditional inference trees

Description

Make all conditional inference trees

Usage

create_ctree(
  given_ind,
  x_train,
  mincriterion,
  minsplit,
  minbucket,
  use_partykit = "on_error"
)

Value

List with conditional inference tree and the variables conditioned/not conditioned on.

Arguments

given_ind

Numeric value. Indicates which features are conditioned on.

x_train

Numeric vector. Indicates the specific values of features for individual i.

mincriterion

Numeric value or vector equal to 1 - alpha where alpha is the nominal level of the conditional independence tests. Can also be a vector equal to the length of the number of features indicating which mincriterion to use when conditioning on various numbers of features.

minsplit

Numeric value. Equal to the value that the sum of the left and right daughter nodes need to exceed.

minbucket

Numeric value. Equal to the minimum sum of weights in a terminal node.

use_partykit

String. In some semi-rare cases partyk::ctree runs into an error related to the LINPACK used by R. To get around this problem, one may fall back to using the newer (but slower) partykit::ctree function, which is a reimplementation of the same method. Setting this parameter to "on_error" (default) falls back to partykit::ctree, if party::ctree fails. Other options are "never", which always uses party::ctree, and "always", which always uses partykit::ctree. A warning message is created whenever partykit::ctree is used.

Author

Annabelle Redelmeier, Martin Jullum

Examples

Run this code
if (requireNamespace("MASS", quietly = TRUE) & requireNamespace("party", quietly = TRUE)) {
  m <- 10
  n <- 40
  n_samples <- 50
  mu <- rep(1, m)
  cov_mat <- cov(matrix(rnorm(n * m), n, m))
  x_train <- data.table::data.table(MASS::mvrnorm(n, mu, cov_mat))
  given_ind <- c(4, 7)
  mincriterion <- 0.95
  minsplit <- 20
  minbucket <- 7
  sample <- TRUE
  create_ctree(
    given_ind = given_ind, x_train = x_train,
    mincriterion = mincriterion, minsplit = minsplit,
    minbucket = minbucket, use_partykit = "on_error"
  )
}

Run the code above in your browser using DataLab