tvcm-methods {vcrpart} | R Documentation |
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'
depth(x, root = FALSE, ...)
## S3 method for class 'tvcm'
extract(object, what = c(
"control", "model",
"nodes", "sctest", "p.value",
"devgrid", "cv", "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'
summary(object, ...)
## S3 method for class 'tvcm'
width(x, ...)
Arguments
object , tree , x |
an object of class |
root |
logical scalar. Should the root count be counted in
|
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 |
na.action |
function determining what should be done with missing
values for fixed effects in |
ranef |
logical scalar or matrix indicating whether prediction
should be based on random effects. See
|
what |
a character specifying the quantities to |
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.
The splitpath
function allows to backtrack the
partitioning procedure. By default, it shows which split was chosen in
the first iteration. The interesting iteration(s) can be selected by
the steps
argument. With details = TRUE
it is also
possible to backtrack the coefficient constancy tests and/or the loss
reduction statistics.
summary
computes summary statistics of the fitted model,
including the estimated coefficients. The varying coefficient are printed
by means of a printed decision tree. Notice that in cases there is no split
for the varying coefficient, the average coefficient will be among the
fixed effects.
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.
Value
The coef.tvcm
and coefficients.tvcm
methods return a list
with model
coefficients. Slot vc
stores varying coefficients, fe
fixed coefficients and re
coefficients on random effects.
The depth.tvcm
method returns a integer vector with
the depth of the trees of every varying
coefficient. width.tvcm
returns a integer vector with
the width of the trees.
The extract
and extract.tvcm
methods
allow to extract further information of tvcm
objects, such as
the underlying regression model. The type of the return value depends
on the input for argument what
.
The formula.tvcm
method extracts the model formula,
which is an object of class formula
. See also
formula
.
The methods fitted.tvcm
and
predict.fvcm
return an object of class numeric
or matrix
, depending on the used model or the specification of
the argument type
.
The getCall.tvcm
method extracts the call for fitting
the model, which is an object of class call
. See also
call
.
The logLik.tvcm
method returns an object of class
logLik
, see also logLik
.
The model.frame.tvcm
method returns a
data.frame
. See also model.frame
.
The neglogLik2.tvcm
method returns a single numeric,
see also neglogLik2
.
The nobs.tvcm
method extracts the number of
observations used to fit the model. See also
nobs.tvcm
.
The print.tvcm
and summary.tvcm
methods return NULL
.
The ranef.tvcm
method returns an object of class
matrix
with values for the random effects. See also
ranef.olmm
and ranef
.
The resid.tvcm
and residuals.tvcm
methods return a numeric
or a matrix
, depending on the
used model or the type of residuals. See the help of the
resid
method of the used model.
The methods splitpath
and
splitpath.tvcm
return an object of class
splitpath.tvcm
that contains information on splitting when
building the tree.
The weights.tvcm
method extracts a numeric
vector with the model weights. See also weights
.
Author(s)
Reto Burgin
See Also
tvcm
, tvcm-assessment
,
tvcm-plot
Examples
## ------------------------------------------------------------------- #
## Dummy example:
##
## 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)