SumTestSens: Rosenbaum Sensitivity Analysis for Unmatched Groups

Description Usage Arguments Value Warning Author(s) References See Also Examples

View source: R/SumTestSens.R

Description

Calculates sensitivity to hidden bias for tests based on sum statistics (e.g., Wilcoxon's rank sum test), following the method described by Rosenbaum (2002, sec. 4.6). It is meant for unmatched/unstratified data with ordinal or continuous responses.

Usage

1
SumTestSens(T, q, n, m, Gamma)

Arguments

T

observed value of the test statistic (e.g., the sum of the ranks of the responses of the treated units; note that a higher rank corresponds to a higher response)

q

vector of functions of the responses (e.g., their ranks), sorted in decreasing order

n

total number of observations

m

number treated units

Gamma

scalar indicating upper limit on the ratio of the a priori odds of treatment assignment between the treated and control groups

Value

This function prints the upper bound of the normal approximation one-sided p-value for the test at the given value of Gamma. It also invisibly returns a list of intermediate statistics.

Warning

Since ‘SumTestSens’ calculates through enumeration the exact expectation and variance of the test under the null, it is very computationally intensive and may be unworkable for even medium-sized datasets.

Author(s)

Devin Caughey, MIT, caughey@mit.edu

References

Paul R. Rosenbaum. Observational Studies. Springer, New York, 2nd edition, 2002, sec. 4.6

See Also

See also data.prep, binarysens, hlsens, Match, mcontrol

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
## Example from Rosenbaum (2002, p.~146)
  mercury <- data.frame(matrix(c(1, 0, 2.7,    5.3,
                                 2, 0, 0.5,   15.0,
                                 3, 0, 0.0,   11.0,
                                 4, 0, 0.0,    5.8,
                                 5, 0, 5.0,   17.0,
                                 6, 0, 0.0,    7.0,
                                 7, 0, 0.0,    8.5,
                                 8, 0, 1.3,    9.4,
                                 9, 0, 0.0,    7.8,
                                10, 0, 1.8,   12.0,
                                11, 0, 0.0,    8.7,
                                12, 0, 0.0,    4.0,
                                13, 0, 1.0,    3.0,
                                14, 0, 1.8,   12.2,
                                15, 0, 0.0,    6.1,
                                16, 0, 3.1,   10.2,
                                17, 1, 0.7,  100.0,
                                18, 1, 4.6,   70.0,
                                19, 1, 0.0,  196.0,
                                20, 1, 1.7,   69.0,
                                21, 1, 5.2,  370.0,
                                22, 1, 0.0,  270.0,
                                23, 1, 5.0,  150.0,
                                24, 1, 9.5,   60.0,
                                25, 1, 2.0,  330.0,
                                26, 1, 3.0, 1100.0,
                                27, 1, 1.0,   40.0,
                                28, 1, 3.5,  100.0,
                                29, 1, 2.0,   70.0,
                                30, 1, 5.0,  150.0,
                                31, 1, 5.5,  200.0,
                                32, 1, 2.0,  304.0,
                                33, 1, 3.0,  236.0,
                                34, 1, 4.0,  178.0,
                                35, 1, 0.0,   41.0,
                                36, 1, 2.0,  120.0,
                                37, 1, 2.2,  330.0,
                                38, 1, 0.0,   62.0,
                                39, 1, 2.0,   12.8),
                               nrow = 39, ncol = 4, byrow = TRUE))
  colnames(mercury) <- c("ID", "Tr", "Pct.cu.cells", "Hg.in.blood")
  
  (T_test <- rank(mercury$Hg.in.blood) %*% mercury$Tr)
  (q_test <- sort(rank(mercury$Hg.in.blood), decreasing = TRUE))
  (n_test <- nrow(mercury))
  (m_test <- sum(mercury$Tr))

  ## Note: since this function uses exact rather than approximate
  ## formulas for the mean and variance of T, the p-values it
  ## calculates do not precisely match those in Rosenbaum (2002).

  #A single Gamma value - example not run
  #testOut2 <- SumTestSens(T = T_test,
  #                         q = q_test,
  #                         n = n_test,
  #                         m = m_test,
  #                         Gamma = 35)
 
  ## Apply to vector of Gamma values
  sapply(c(1, 5, 35), SumTestSens,
         T = T_test, q = q_test, n = n_test, m = m_test) 

Example output

Loading required package: Matching
Loading required package: MASS
## 
##  Matching (Version 4.9-2, Build Date: 2015-12-25)
##  See http://sekhon.berkeley.edu/matching for additional documentation.
##  Please cite software as:
##   Jasjeet S. Sekhon. 2011. ``Multivariate and Propensity Score Matching
##   Software with Automated Balance Optimization: The Matching package for R.''
##   Journal of Statistical Software, 42(7): 1-52. 
##

     [,1]
[1,]  642
 [1] 39.0 38.0 36.5 36.5 35.0 34.0 33.0 32.0 31.0 30.0 28.5 28.5 27.0 25.5 25.5
[16] 23.5 23.5 22.0 21.0 20.0 19.0 18.0 17.0 16.0 15.0 14.0 13.0 12.0 11.0 10.0
[31]  9.0  8.0  7.0  6.0  5.0  4.0  3.0  2.0  1.0
[1] 39
[1] 23
For Gamma = 1, the upper-bound on the p-value of the sum test is: < 1e-04.
For Gamma = 5, the upper-bound on the p-value of the sum test is: 3e-04.
For Gamma = 35, the upper-bound on the p-value of the sum test is: 0.0256.
           [,1]          [,2]          [,3]         
pValueUB   1.009833e-07  0.0003477962  0.02559196   
minDeviate 5.197518      3.391311      1.949935     
deviate    Numeric,40    Numeric,40    Numeric,40   
kMin       Integer,40    22            23           
T          642           642           642          
mu.T       Numeric,40    Numeric,40    Numeric,40   
var.T      Numeric,40    Numeric,40    Numeric,40   
sd.T       Numeric,40    Numeric,40    Numeric,40   
rho.i      Numeric,1560  Numeric,1560  Numeric,1560 
rho.ij     Numeric,60840 Numeric,60840 Numeric,60840

rbounds documentation built on May 2, 2019, 6:11 a.m.

Related to SumTestSens in rbounds...