Can be used to carry out inference on a pair of sibling regions or on a single region.

branchInference(
  tree,
  branch,
  type = "reg",
  alpha = 0.05,
  sigma_y = NULL,
  c = 0,
  computeCI = TRUE,
  permute = FALSE
)

Arguments

tree

An rpart object corresponding to the tree that you wish to do inference on. This tree must have been built with rpart parameter model=TRUE.

branch

A vector of splits describing the branch that you wish to do inference on. You should obtain this using the function `getBranch()`. Must actually correspond to a branch in tree.

type

A string that should be set to either "reg" (default) or "sib". This specifies whether you are doing inference on the mean of single region at the end of this branch ("reg"), or doing inference on the difference between this region and its sibling.

alpha

Function will compute an equi-tailed (1-alpha) confidence interval. Default is 0.05.

sigma_y

The true standard deviation of the response. If known, this should be passed in. Otherwise, the sample standard deviation will be used as a conservative estimate.

c

The p-value returned will test the null hypothesis that the parameter of interest is equal to c. Currently, only c=0 is a valid input.

computeCI

Boolean that specifies if you would like a confidence interval to be computed. Confidence intervals are much slower to compute than p-values, and so if you only wish to see a p-value you may want to set this to be false.

permute

Boolean. Only relevant if type="reg". If FALSE (default), inference is conducted conditional on the event that this exact branch appeared in the tree. If TRUE, inference is conducted conditional on the event that some permutation of this branch appeared in the tree. While the latter achieves higher power, it can be computationally prohibitive in large trees.

Value

An object of class branch_inference that contains a confidence interval, a p-value, the sample statistic, the conditioning set, and a flag reminding the user if type="reg" or type="sib".

Examples

bls.tree <- rpart::rpart(kcal24h0~hunger+disinhibition+resteating+rrvfood+liking+wanting, model = TRUE, data = blsdata, cp=0.02) branch <- getBranch(bls.tree, 8) branchInference (bls.tree, branch, type="sib")
#> #> Sample statistic: -435.6817 #> 95% confidence interval: -1106.747, 136.5523 #> Type: sib #> p-value for test that param=0: 0.9002555 #> Conditioning Set: #> Object of class Intervals_full #> 2 intervals over R: #> (-543.236399481531, -428.125574226105) #> (428.125574226104, 929.97322312961)
branchInference (bls.tree, branch, type="reg", permute=TRUE)
#> #> Sample statistic: 1294.109 #> 95% confidence interval: 253.7905, 2148.2956 #> Type: reg #> p-value for test that param=0: 0.01663048 #> Conditioning Set: #> Object of class Intervals_full #> 2 intervals over R: #> (1224.75070250313, 1301.6652990799) #> (2868.72223626769, 3427.28431563896)