rpart
regression tree.R/user_funs.R
branchInference.Rd
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 )
tree | An |
---|---|
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 |
type | A string that should be set to either |
alpha | Function will compute an equi-tailed |
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 |
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"
.
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)