Learn R Programming

gamlss.add (version 5.1-13)

tr: A interface function to use rpart() function within GAMLSS

Description

The tr() function is a additive function to be used for GAMLSS models. It is an interface for the rpart() function of package rpart. The function tr() allows the user to use regression trees within gamlss. The great advantage of course comes from the fact GAMLSS models provide a variety of distributions and diagnostics. Note that the function gamlss.tr is not used by the user but it needed for the backfitting.

Usage

tr(formula, method = c("rpart"), control = rpart.control(...), ...)
gamlss.tr(x, y, w, xeval = NULL, ...)

Value

Note that tr itself does no smoothing; it simply sets things up for the function gamlss() which in turn uses the function additive.fit() for backfitting which in turn uses gamlss.tr()

The result is a rpart object.

Arguments

formula

A formula containing the expolanatory variables i.e. ~x1+x2+x3.

method

only method "rpart" is supported at the moment

control

control here is equivalent to rpart.control() function od package rpart

x

object passing informatio to the function

y

the iterative y variable

w

the iterative weights

xeval

whether prediction or not is used

...

additional arguments

Author

Mikis Stasinopoulos mikis.stasinopoulos@gamlss.org, Bob Rigby based on work of Therneau and Atkison (2015)

Details

Note that, the gamlss fit maybe would not coverged. Also occasianly the gd.tol argument in gamlss has to be increased. The

References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.

Rigby R.A., Stasinopoulos D. M., Heller G., and De Bastiani F., (2019) Distributions for Modeling Location, Scale and Shape: Using GAMLSS in R, Chapman and Hall/CRC.

Ripley, B. D. (1996) Pattern Recognition and Neural Networks. Cambridge.

Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, 23(7), 1--46, tools:::Rd_expr_doi("10.18637/jss.v023.i07")

Stasinopoulos D. M., Rigby R.A., Heller G., Voudouris V., and De Bastiani F., (2017) Flexible Regression and Smoothing: Using GAMLSS in R, Chapman and Hall/CRC.

(see also https://www.gamlss.com/).

Therneau T. M., Atkinson E. J. (2015) An Introduction to Recursive Partitioning Using the RPART Routines. Vignette in package rpart.

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

See Also

See Also as nn

Examples

Run this code
data(rent)
#--- fitting gamlss+tree Nornal
library(rpart)
data(rent)
rg1 <- gamlss(R ~ tr(~A+Fl), data=rent, family=NO)
plot(rg1)
plot(getSmo(rg1))
text(getSmo(rg1))
if (FALSE) {
# fitting Gamma  errors
rg2 <- gamlss(R ~ tr(~A+Fl), data=rent, family=GA)
plot(rg2)
plot(getSmo(rg2))
text(getSmo(rg2))
#--- fitting also model in the variance
rg3 <- gamlss(R ~ tr(~A+Fl), sigma.fo=~tr(~Fl+A), data=rent, 
                family=GA, gd.tol=100, c.crit=0.1)
plot(rg3)
plot(getSmo(rg3))
text(getSmo(rg3))
plot(getSmo(rg3, what="sigma"))
text(getSmo(rg3, what="sigma"))}

Run the code above in your browser using DataLab