Skip to contents

Draws n_draws assignments of n_treated treated places out of n and returns, per place, the share of draws in which it sat at each exposure level of morie_spillover_exposure. Exact enumeration is used when it is small enough. Monte Carlo draws come from the Philox stream: draw k treats the n_treated places with the smallest of the uniforms (k - 1) n + 1, ..., k n of .morie_random_uniform(n * n_draws, seed, stream = 0), so the R and Python arms return identical probabilities for the same seed.

Usage

morie_spillover_exposure_probs(
  n,
  edges,
  n_treated,
  n_draws = 5000L,
  exact_max = 20000,
  joint = FALSE,
  seed = 0
)

Arguments

n

Number of places.

edges

Adjacency as in morie_spillover_exposure.

n_treated

Number of treated places per assignment.

n_draws

Monte Carlo draws (ignored when exact enumeration is feasible).

exact_max

Enumerate all assignments when choose(n, n_treated) is at most this.

joint

Also return the joint probabilities \(\pi_{ij}(\ell) = P(E_i = \ell, E_j = \ell)\) needed for the variance in morie_spillover_ht.

seed

Philox seed for the Monte Carlo branch (non-negative).

Value

An n by 3 matrix of exposure probabilities (columns "0", "1", "2"); with joint = TRUE a list with marginal (that matrix) and joint (an n by n by 3 array).

Examples

morie_spillover_exposure_probs(n = 6, edges = cbind(1:5, 2:6), n_treated = 2)
#>        0         1         2
#> [1,] 0.4 0.2666667 0.3333333
#> [2,] 0.2 0.4666667 0.3333333
#> [3,] 0.2 0.4666667 0.3333333
#> [4,] 0.2 0.4666667 0.3333333
#> [5,] 0.2 0.4666667 0.3333333
#> [6,] 0.4 0.2666667 0.3333333