build_MOTTE_forest_CO: buildForest

Description Usage Arguments Value Examples

View source: R/build_MOTTE_forest_y.R

Description

The function to fitting tree/trees

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
build_MOTTE_forest_CO(
  x.b,
  x.diff.1,
  x.diff.2,
  y.diff.1,
  y.diff.2,
  nsplits = NULL,
  nodesize = 2 * (ncol(x.b) + 1),
  left.out = 0.1,
  ntree = ifelse(is.null(nsplits), 1, 200),
  nCore = ifelse(is.null(nsplits), 1, detectCores() - 1)
)

Arguments

x.b

Before treatment covariates, a n by p matrix

nsplits

The number of split condidate want to examine when constructing split rule

nodesize

Parameter to control the node size. When the number of observations in Node smaller than nodesize, stop splitting

left.out

left.out is ensure at least left.out*2 sample for either treated or untreated sample in the group

ntree

Number of trees want to construct. By default it is 1; however, when Random method used, recommand setting it as 200

nCore

The number of cores use for forest contruction when doing parallel computation

x.e

After treatment covariates, a n by p matrix

treat

Treatment received, a n by 1 vector

y.b

Before treatment outcomes, a n by q matrix

y.e

After treatment outcomes, a n by q matrix #@param method Method to use when choosing split value. Two options: "Exhaust" and "Random"

Value

a list of data.tree. Even when only one tree construct, it is a list containing the single tree

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#' set.seed(1)
B <- create.B(10)
Z <- create.Z(10, 3)

tmp.dat <- sim_MOTTE_data( n.train = 500, n.test = 200,
p = 10, q = 3, ratio = 0.5,
B = B, Z = Z)

train.dat <- tmp.dat$train

x.b <- scale(train.dat$x.b, center = FALSE, scale = TRUE)
x.e <- scale(train.dat$x.e, center = FALSE, scale = TRUE)
y.b <- scale(train.dat$y.b, center = FALSE, scale = TRUE)
y.e <- scale(train.dat$y.e, center = FALSE, scale = TRUE)
treat <- train.dat$trt

# with(train.dat,
    build_MOTTE_forest(x.b, x.e, treat, y.b, y.e)
#)

boyiguo1/MOTTE.RF documentation built on June 14, 2020, 4:12 p.m.