extree_data: Data Preprocessing for Extensible Trees.

Description Usage Arguments Details Value Examples

View source: R/extree.R

Description

A routine for preprocessing data before an extensible tree can be grown by extree_fit.

Usage

1
2
3
4
extree_data(formula, data, subset, na.action = na.pass, weights, offset, 
            cluster, strata, scores = NULL, yx = c("none", "matrix"),
            ytype = c("vector", "data.frame", "matrix"), 
            nmax = c(yx = Inf, z = Inf), ...)

Arguments

formula

a formula describing the model of the form y1 + y2 + ... ~ x1 + x2 + ... | z1 + z2 + ....

data

an optional data.frame containing the variables in the model.

subset

an optional vector specifying a subset of observations to be used in the fitting process.

na.action

a function which indicates what should happen when the data contain missing values.

weights

an optional vector of weights.

offset

an optional offset vector.

cluster

an optional factor describing clusters. The interpretation depends on the specific tree algorithm.

strata

an optional factor describing strata. The interpretation depends on the specific tree algorithm.

scores

an optional named list of numeric scores to be assigned to ordered factors in the z part of the formula.

yx

a character indicating if design matrices shall be computed.

ytype

a character indicating how response variables shall be stored.

nmax

a numeric vector of length two with the maximal number of bins in the response and x-part (first element) and the z part. Use Inf to switch-off binning.

...

additional arguments.

Details

This internal functionality will be the basis of implementations of other tree algorithms in future versions. Currently, only ctree relies on this function.

Value

An object of class extree_data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  data("iris")

  ed <- extree_data(Species ~ Sepal.Width + Sepal.Length | Petal.Width + Petal.Length, 
                    data = iris, nmax = c("yx" = 25, "z" = 10), yx = "matrix")

  ### the model.frame
  mf <- model.frame(ed)
  all.equal(mf, iris[, names(mf)])

  ### binned y ~ x part
  model.frame(ed, yxonly = TRUE)

  ### binned Petal.Width
  ed[[4, type = "index"]]

  ### response
  ed$yx$y

  ### model matrix 
  ed$yx$x

partykit documentation built on Aug. 23, 2021, 5:10 p.m.