FRT: Runs a Conditional Fisher Randomization Test

Description Usage Arguments Examples

View source: R/frt.R

Description

This function tests the null that H_0: Y(k) = Y(l) where 'k' and 'l' are the exposures of interest. The test statistic 'T' should be inputable (see description of argument).

Usage

1
FRT(Zobs, Yobs, T, A, k, l, n.rand = 1000, two.sided = FALSE)

Arguments

Zobs

A list of numeric vectors. A group-assignment structure.

Yobs

A numeric vector of observed outcomes.

T

A function representing the test statistic. This function is called as followed in the code: 'T(W, Yobs.u, k, l, A.u)' where W, Yobs.u and A are the subsets of the exposure vector, observed outcomes vector and attribute vectors (respectively) for the focal units. The statistics 'T.dim' and 'T.studentized' can be used out of the box.

A

A numeric vector of attributes.

k

An integer representing an exposure value.

l

An integer representing an exposure value.

n.rand

An integer. The number of draws to use to build the (conditional) null distribution of the test statistic (defaults to 1000).

two.sided

A boolean. Whether to report a one-sided or two-sided p-value (defaults to FALSE).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# setup
N <- 90 # number of units
M <- 3 # number of units in each (equal-sized) group
A <- rep(c(0,1), each = N/2) # vector of binary attributes
L0 <- find.good.L0(N, M, 1000)

# generating a schedule of potential outcomes
# (for which H0^{0,1} is true, but H0^{0,2} is not).
Y0 <- rnorm(N)
science = cbind(Y0, Y0, Y0+1)
colnames(science) <- NULL

# Observing the assignments and outcomes
L <- rsL(L0, A, 1000)
Zobs <- Z.fn(L)
Yobs <- observe.outcomes(Zobs, A, science)

# running the tests
FRT(Zobs, Yobs, T.dim, A, 1, 0)
FRT(Zobs, Yobs, T.dim, A, 2, 0)

gwb/RGroupFormation documentation built on Sept. 13, 2020, 4:41 p.m.