Based on the similar function from the Outference package, which accomplishes a similar task. Code modified from code found at https://github.com/shuxiaoc/outference. This function shouldn't be needed by most users (it is called internally by branchInference()), but is needed to reproduce our paper simulations.

correctPVal(phiInterval, nu, y, sigma)

Arguments

phiInterval

the conditioning set (truncation interval). An object of class Interval, where the rows represent the union of disjoint intervals on the real line.

nu

the vector that defines the parameter of interest. We are testing the hypothesis that nu^T mu = 0.

y

the response data y.

sigma

the (assumed known) noise standard deviation. The assumption is that y_i ~ N(mu_i, sigma^2).

Value

a p-value.

Examples

data(blsdata, package="treevalues") bls.tree <-rpart::rpart(kcal24h0~hunger+disinhibition+resteating+rrvfood+liking+wanting, model = TRUE, data = blsdata, cp=0.02) branch <- getBranch(bls.tree, 2) left_child <- getRegion(bls.tree,2) right_child <- getRegion(bls.tree,3) nu_sib <- left_child/sum(left_child) - right_child/sum(right_child) S_sib <- getInterval(bls.tree, nu_sib,branch) correctPVal(S_sib, nu_sib, blsdata$kcal24h0, sd(blsdata$kcal24h0))
#> [1] 0.4425364
# Same answer as using branchInference() branchInference(bls.tree, branch, type="sib")$pval
#> [1] 0.4425364