Skip to contents

Thin extender over rdlocrand::rdrandinf for finite-sample randomisation-inference around the cutoff window (Cattaneo, Frandsen & Titiunik, 2015; Cattaneo, Titiunik & Vazquez-Bare, 2016).

Usage

morie_rdd_local_randinf(Y, R, wl, wr, ...)

Arguments

Y

Numeric outcome vector.

R

Numeric running / forcing variable.

wl

Numeric scalar; left edge of the randomisation window.

wr

Numeric scalar; right edge of the randomisation window.

...

Further arguments forwarded to rdlocrand::rdrandinf (e.g. statistic, p, nulltau, reps, seed).

Value

A list with $method = "rdlocrand::rdrandinf" and $raw (an rdrandinf object with the randomisation-inference p-values and the observed statistic).

Examples

# \donttest{
  if (requireNamespace("rdlocrand", quietly = TRUE)) {
    set.seed(1)
    R <- runif(200, -1, 1)
    Y <- 0.5 * R + (R >= 0) * 0.3 + rnorm(200, sd = 0.5)
    morie_rdd_local_randinf(Y, R, wl = -0.1, wr = 0.1)
  }
#> 
#> Selected window = [-0.1;0.1] 
#> 
#> Running randomization-based test...
#> Randomization-based test complete. 
#> 
#> 
#> Number of obs     =           200
#> Order of poly     =             0
#> Kernel type       =       uniform
#> Reps              =          1000
#> Window            =   set by user
#> H0:          tau  =         0.000
#> Randomization     = fixed margins
#> 
#> Cutoff c =    0.000   Left of c  Right of c
#>       Number of obs          98         102
#>  Eff. number of obs          15           9
#>     Mean of outcome       0.043       0.060
#>     S.d. of outcome       0.455       0.514
#>              Window      -0.100       0.100
#> 
#> ================================================================================
#>                                   Finite sample            Large sample         
#>                                ------------------  -----------------------------
#>           Statistic          T        P>|T|        P>|T|    Power vs d =   0.228
#> ================================================================================
#>      Diff. in means      0.018        0.931        0.932                   0.195
#> ================================================================================
#> $method
#> [1] "rdlocrand::rdrandinf"
#> 
#> $raw
#> $raw$sumstats
#>             [,1]         [,2]
#> [1,] 98.00000000 102.00000000
#> [2,] 15.00000000   9.00000000
#> [3,]  0.04252159   0.06026457
#> [4,]  0.45547204   0.51364133
#> [5,] -0.10000000   0.10000000
#> 
#> $raw$obs.stat
#> [1] 0.01774298
#> 
#> $raw$p.value
#> [1] 0.931
#> 
#> $raw$asy.pvalue
#> [1] 0.9319268
#> 
#> $raw$window
#> [1] -0.1  0.1
#> 
#> 
# }