Learn R Programming

GPLTR (version 1.2)

tree2glm: tree to GLM

Description

fit the PLTR model for a given tree. The tree is coerced into dummy covariates.

Usage

tree2glm(xtree, xdata, Y.name, X.names, family = "binomial")

Arguments

xtree

a tree inherits from the rpart method

xdata

a data frame containing the variables in the model

Y.name

the name of the dependent variable

X.names

the names of independent variables to consider in the linear part of the glm

family

the glm family considered depending on the type of the dependent variable.

Value

the pltr fitted model (fit)

Examples

Run this code
# NOT RUN {
##load the data set

data(data_pltr)

## set the parameters

args.rpart <- list(minbucket = 40, cp = 0)
family <- "binomial"
Y.name <- "Y"
X.names <- "G1"
G.names <- paste("G", 2:15, sep="")

## build a maximal tree

fit_pltr <- pltr.glm(data_pltr, Y.name, X.names, G.names, args.rpart = args.rpart,
                     family = family,iterMax = 5, iterMin = 3)
                     
## Coerce a tree into a glm model using the confonding factor                     

fit_glm <- tree2glm(fit_pltr$tree, data_pltr, Y.name, X.names,
                    family = family)
                    
summary(fit_glm)
# }

Run the code above in your browser using DataLab