create_ctree: Make all conditional inference trees

Description Usage Arguments Value Author(s) Examples

View source: R/sampling.R

Description

Make all conditional inference trees

Usage

1
2
3
4
5
6
7
8
create_ctree(
  given_ind,
  x_train,
  mincriterion,
  minsplit,
  minbucket,
  use_partykit = "on_error"
)

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.

Value

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

Author(s)

Annabelle Redelmeier, Martin Jullum

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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"
  )
}

shapr documentation built on Jan. 28, 2021, 5:06 p.m.