Learn R Programming

BayesTreePrior (version 1.0.1)

BayesTreePriorNotOrthogonal: Simulation of the tree prior in the general case (Case #4).

Description

Generate $n_{iter}$ trees from the prior distribution in the general case (Case #4).

Usage

BayesTreePriorNotOrthogonal(alpha, beta, X, n_iter = 500, minpart = 1, pvars = NULL, MIA = FALSE, missingdummy = FALSE)

Arguments

alpha
base parameter of the tree prior, $\alpha \in [0,1)$.
beta
power parameter of the tree prior, $\beta \geq 0$.
X
data.frame of the design matrix.
n_iter
number of trees to generate, $n_{iter}>0$.
minpart
the minimum number of observations required in one of the child to be able to split, $minpart>0$.
pvars
vector of probabilities for the choices of variables to split (Will automatically be normalized so that the sum equal to 1). It must be twice as large as the number of variables when $missingdummy$ is TRUE.
MIA
set to TRUE if you want Missing Incorporated in Attributes (MIA) imputation to be used.
missingdummy
set to TRUE if you have dummy coded the NAs.

Value

Returns a list containing, in the following order: the mean number of bottom nodes, the standard deviation of the number of bottom nodes, the mean of the depth, the standard deviation of the depth and a data.frame of vectors $(b_i,d_i)$, where $b_i$ is the number of bottom nodes and $d_i$ is the depth of the $i$th generated tree ($i=1, \ldots ,n_{iter}$).

See Also

BayesTreePriorOrthogonalInf, BayesTreePriorOrthogonal

Examples

Run this code
if (requireNamespace("MASS", quietly = TRUE)) {
    x1 = MASS::mcycle$times
    x1[sample(1:length(x1), 20)] <- NA
    x2= MASS::mcycle$accel
    x2[sample(1:length(x2), 20)] <- NA
    X = cbind(x1, x2)
    results1 = BayesTreePriorNotOrthogonal(.95,.5, data.frame(X), minpart=5)
    X_dummies = is.na(X) + 0
    results2 = BayesTreePriorNotOrthogonal(.95,.5, data.frame(cbind(X,X_dummies)), minpart=5, 
    MIA=TRUE, missingdummy=TRUE)
}

Run the code above in your browser using DataLab