ItltTree: Implement tree structured subgroup identification on...

Description Usage Arguments Value Examples

View source: R/itlt_tree.R

Description

Methods implemented include: mixed effects based method (LRT based method), GEE based method, multiple test based method, multivariate multiple regression (mmp) based method. mixed effects and GEE are for regular longitudinal datasets and multiple test based and mmp based method are for intensive longitudinal datasets. This function is based on partynode package. Also interaction trees by scalar based methods (avg, last-k) are also implemented.But the scalar based method needs to have the same data format (see data, fm, tf for details), otherwise regular code for interaction tree could be used

Usage

1
2
3
ItltTree(data, fm, tf, split.covs, nknot = 5, p.value = 1,
  delta = 0.1, nCutpoints = 20, minsplit = 20, size.limit = 10,
  maxdepth = 3, details = "TRUE", alpha = 2.5, model = "bslme")

Arguments

data

dataset in wide format, please see fm and time frame for column name restrictions. Also data must have a column named "id", otherwise the first column will be specified to be "id"

fm

formula of the form "response name ~ treatment name". data must contain column names of the response with all its time frames. For instance, if fm = "y~treatment", tf = 1:12, then columns names in the dataset must include y1, y2,..., y12. And these longitudinal observations will be used as reponse for subgroup identfication

tf

time frame

split.covs

splitting covariates, vector of strings

nknot

knot numbers, for multiple test based and mmp based methods, nknot <= 0 means automatic selection of knot numbers using GCV

p.value

significance level for a node to be considered, default is 1

delta

lower bound of the ratio of the size of the child node and the parent node, default is 0.1

nCutpoints

number of cutoff points for a continuous splitting covariate, default is 20

minsplit

minimum number of samples for a node to be considered for splitting, default is 30

size.limit

minimum size for a node, default is delta * minsplit

maxdepth

maximum depth of the tree, default is 4

details

whether details in the treee building process will be printed, default is FALSE

alpha

tuning parametering in the selection of knot numbers using smoothing splines, specific for multiple test based method and MMP based method, default is 2

model

method to be implemented.

Value

identified tree of partynode type

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
library(itlt)
data <- ItltSimulation1(250, 1:12, type = 2)
ItltTree(data, as.formula(y~treatment), 1:12, paste0("X", 1:10))

library("glmertree")
library("splines")

wide.to.long <- function(data, name, cov.names) {
  y.names <-
    colnames(data)[sapply(colnames(data), function(x) {
      return(startsWith(x, name))
    })]
  y <- matrix(t(data[, y.names]))
  N.time <- length(y.names)
  cov <- data[rep(1:nrow(data), each = N.time), cov.names]
  rownames(cov) <- NULL
  result <- cbind(cov, y)
  result <-
    cbind(result, rep(0:(length(y.names) - 1), nrow(data)), rep(data$group, length(y.names)))
  colnames(result)[c(ncol(result) - 1, ncol(result))] <-
    c('time', 'group')

  result <- result[!is.na(y),]

  result
}

data <- ItltSimulation1(250, 1:12, type = 2)
t <- colnames(data)
data.long <- wide.to.long(data, "y", t[!startsWith(t, "y")])
data.lmetree <-
  lmertree(
    as.formula(
      paste0(
        "y ~ treatment*bs(time, df=5, degree=3, intercept=FALSE) | id |",
        paste0("X", 1:10, collapse = "+")
      )
    ),
    cluster = id,
    data = data.long,
    maxdepth = 3,
    alpha = .01
  )$tree

yishuwei2019/itlt documentation built on July 8, 2021, 5:15 p.m.