Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

extree_data

Data Preprocessing for Extensible Trees.


Description

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

Usage

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

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

A Toolkit for Recursive Partytioning

v1.2-13
GPL-2 | GPL-3
Authors
Torsten Hothorn [aut, cre] (<https://orcid.org/0000-0001-8301-0471>), Heidi Seibold [ctb] (<https://orcid.org/0000-0002-8960-9642>), Achim Zeileis [aut] (<https://orcid.org/0000-0003-0918-3766>)
Initial release
2021-03-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.