sample_gs_walk: Sample from the Gram-Schmidt Walk design.

Description Usage Arguments Value Examples

View source: R/sample_gsw.R

Description

An fast implementation for sampling from the Gram-Schmidt Walk Design. Maintains a cholesky factorization of (I + A * A^T ) for faster repeated linear system solves and has a recursive component for more effective memory allocation.

Usage

1
2
3
4
5
6
7
8
9
sample_gs_walk(X, phi, balanced = FALSE, treatment_probs = 0.5)

sample_many_gs_walk(
  X,
  phi,
  num_samples,
  balanced = FALSE,
  treatment_probs = 0.5
)

Arguments

X

a n-by-x matrix with covariates to balance

phi

a real value in (0,1) specifying the balancing weight

balanced

set true to run the balanced version of the GSW design

treatment_probs

a vector of marginal assignment probabilities. If scalar, the probabilities for all units are set to the provided value.

num_samples

number of treatment assignments to sample.

Value

sample_gs_walk returns a single logical vector containing the assignments. sample_many_gs_walk returns a list of num_samples such vectors.

Examples

1
2
3
4
5
6
7
8
## Not run: 
gswdesign_setup()
set_julia_seed(123456789L)
X <- matrix(rnorm(1000), nrow = 100)
assignment <- sample_gs_walk(X, 0.3)
assignments <- sample_many_gs_walk(X, 0.3, 1000L)

## End(Not run)

fsavje/gswdesign-R documentation built on Aug. 9, 2020, 7:48 p.m.