causal_XTY_binary: Simulating a causal data set S = (X,T,Y_0, Y_1, Y_{obs}) with...

Description Usage Arguments Value Examples

View source: R/generate_causal.R

Description

Creates a causal data set S = (X,T,Y_0, Y_1, Y_{obs}) for causal inference. The p columns of X are sampled from an independent Gaussian distribution with mean μ_i with standard deviation σ_i, i.e. N(μ_i, σ_i^2). The observations Y_0, Y_1 correspond to the outcome if the treatment T is 0 or 1, respectively. A binary treatment T taking values 0 or 1 is sampled with probability p_{treatment} and Y_{obs} is obtained by choosing the potential outcome (either Y_0 or Y_1) corresponding to the sampled treatment T. The base outcome Y = X^T β is assumed to depend on X in a linear fashion, and the average treatment effect corresponds to the additive effect of obtaining treatment T = 1. See Causality (Pearl 2009) for further details and a general introduction to causal inference.

Usage

1
2
3
4
5
6
7
8
causal_XTY_binary(
  n = 100,
  mu = rep(0, 4),
  sigma = rep(1, 4),
  beta_coefficients = 1:4,
  treatment_prob = 0.5,
  treatment_effect = 10
)

Arguments

n

The desired number of data points in the data set.

mu

A p-dimensional vector of means for μ.

sigma

A p-dimensional vector of non-negative standard deviations for σ.

beta_coefficients

A p-dimensional vector of coefficients for β.

treatment_prob

A probability between 0 and 1 specifying the probability of treatment assignment p_{treatment}.

treatment_effect

The average treatment between two potential outcomes Y_0 and Y_1.

Value

A causal data set S = (X,T,Y_0, Y_1, Y_{obs}). In the default case, the p columns X_i are sampled from N(0,1) and the coefficients are all 1. We also have n = 100, p = 4, with beta-coefficients 1 to 4. The base treatment probability is 0.5 (i.e. a coin flip), with the default average treatment effect set to 10.

Examples

1
2
3
4
causal_XTY_binary()

causal_XTY_binary(n = 40, mu = 1:7, sigma = rep(1, 7),
                  beta_coefficients = 1:7, treatment_prob = 0.75, treatment_effect = 25)

lamke07/stat545lamke07 documentation built on Dec. 21, 2021, 8:49 a.m.