Learn R Programming

ri (version 0.9)

invert.ci: Confidence intervals through test inversion

Description

Experimental code to generate endpoints of Rosenbaum (2002)-style confidence intervals through inversion of a constant effects hypothesis. Only conducts inference with the difference in (weighted) means as the test statistic, no covariate adjustment.

Usage

invert.ci(Y, Z, prob, perms, targetp)

Arguments

Y
numeric vector of length N, outcome variable
Z
binary vector (0 or 1) of length N, treatment indicator
prob
numeric vector within the (0,1) interval of length N, probability of treatment assignment, as outputted by genprob() or genprobexact(). When prob=NULL (the default), assumes uniform probability of assignment to treatment equal to the mean of Z
perms
N-by-r permutation matrix, as output by genperms or genperms.custom
targetp
target p-value for the endpoint of the confidence interval

Value

returns endpoint of the confidence interval with the target p-value associated

References

Gerber, Alan S. and Donald P. Green. 2012. Field Experiments: Design, Analysis, and Interpretation. New York: W.W. Norton.

Rosenbaum, Paul R. 2002. Observational Studies. 2nd ed. New York: Springer.

Examples

Run this code
y <- c(8,6,2,0,3,1,1,1,2,2,0,1,0) 
Z <- c(1,1,0,0,1,1,0,0,1,1,1,1,0)

perms <- genperms(Z) ## all possible permutations of assignment to treatment
probs <- genprobexact(Z) ## assuming complete randomization

c(invert.ci(y,Z,probs,perms,0.025),invert.ci(y,Z,probs,perms,0.975)) ## 95% CI

Run the code above in your browser using DataLab