Learn R Programming

vcrpart (version 0.2-1)

tvcm-methods: Methods for tvcm objects

Description

Standard methods for computing on tvcm objects.

Usage

## S3 method for class 'tvcm':
coef(object, ...)

## S3 method for class 'tvcm': extract(object, what = c( "control", "model", "nodes", "sctest", "p.value", "lossgrid", "selected", "coef", "sd", "var"), steps = NULL, ...)

## S3 method for class 'tvcm': neglogLik2(object, ...)

## S3 method for class 'tvcm': predict(object, newdata = NULL, type = c("link", "response", "prob", "class", "node", "coef", "ranef"), ranef = FALSE, na.action = na.pass, ...)

## S3 method for class 'tvcm': splitpath(tree, steps = 1L, details = FALSE, ...)

## S3 method for class 'tvcm': prunepath(tree, steps = 1L, ...)

## S3 method for class 'tvcm': summary(object, ...)

Arguments

object, tree
an object of class tvcm.
steps
integer vector. The iteration steps from which information should be extracted.
newdata
an optional data frame in which to look for variables with which to predict, if omitted, the fitted values are used.
type
character string. Denotes for predict the type of predicted value. See predict.glm or p
na.action
function determining what should be done with missing values for fixed effects in newdata. The default is to predict NA: see na.pass.
ranef
logical scalar or matrix indicating whether prediction should be based on random effects. See predict.olmm.
what
a character specifying the quantities to extract.
details
logical scalar. Whether detail results like coefficient constancy tests or loss minimizing grid search should be shown.
...
Additional arguments passed to the calls.

Details

The predict function has two additional options for the type argument. The option "node" calls the node id and "coef" predicts the coefficients corresponding to an observation. In cases of multiple vc terms for the same predictor, the coefficients are summed up.

splitpath and prunepath are new methods to trace the splitting resp. pruning procedures. They shows several information, such as the loss reduction of new splits during partitioning or the loss reduction of collapsing an inner node when pruning. Further undocumented, available methods are: fitted, formula, getCall, logLik, model.frame, nobs, print, ranef, resid, and weights. All these methods have the same arguments as the corresponding default methods.

See Also

tvcm, tvcm-assessment, tvcm-plot

Examples

Run this code
## ------------------------------------------------------------------- #
## Dummy example 1:
##
## Apply various methods on a 'tvcm' object fitted on the 'vcrpart_2'
## data. Cross-validation is omitted to accelerate the computations.
## ------------------------------------------------------------------- #

data(vcrpart_2)

model <- tvcm(y ~ -1 + vc(z1, z2) + vc(z1, z2, by = x1) + x2,
              data = vcrpart_2, family = gaussian(), subset = 1:90,
              control = tvcm_control(cv = FALSE))

coef(model)
extract(model, "selected")
extract(model, "model")
predict(model, newdata = vcrpart_2[91:100,], type = "node")
predict(model, newdata = vcrpart_2[91:100,], type = "response")
splitpath(model, steps = 1)
summary(model, digits = 2)

Run the code above in your browser using DataLab