DataSimClass-ClusterMixture: Cluster mixture data example

ClusterMixtureR Documentation

Cluster mixture data example

Description

Generates data with covariates drawn from well-separated clusters. Treatment and the outcome both depend on the cluster through a pattern that no quadratic function of the cluster centers explains, so balancing the covariate means and covariances does not remove the confounding.

Value

An R6 object of class DataSim

Super class

DataSim -> ClusterMixture

Methods

Public methods

Inherited methods

ClusterMixture$gen_data()

Generates the data

Usage
ClusterMixture$gen_data()

ClusterMixture$gen_x()

Generates the covariate data

Usage
ClusterMixture$gen_x()

ClusterMixture$gen_y()

Generates the outcome data

Usage
ClusterMixture$gen_y()

ClusterMixture$gen_z()

Generates the treatment indicator

Usage
ClusterMixture$gen_z()

ClusterMixture$new()

Generates the the ClusterMixture R6 class

Usage
ClusterMixture$new(n = 100, p = 2, param = list(), overlap = "low", ...)
Arguments
n

The number of observations

p

The dimensions of the covariates. At least 2; covariates past the second are noise.

param

The data generating parameters fed as a list.

overlap

One of "low" or "high". See details.

...

Extra arguments. Currently unused.

Details
Covariates

Each unit falls in one of nine equally likely clusters centered on the grid \{-2, 0, 2\}^2. Given its cluster k, (X_1, X_2) \sim N(c_k, 0.4^2 I_2) and the remaining covariates are N(0, 1).

Outcome

Y(0) = Y(1) = \beta_1 \ell_k + \beta_2 (X_1 + X_2)/2 + \eta, where the cluster level \ell_k is the residual of c_{k1}^2 c_{k2}^2 after regressing it on all quadratic functions of the centers, scaled to unit variance. Defaults are \beta = (2, 1) and \eta \sim N(0, 1).

Overlap

The treatment indicator is Z \sim Bernoulli(logit^{-1}(a \ell_k + 0.5 (X_1 + X_2)/2)), where a = 1 if overlap is "low" and a = 0.5 if overlap is "high".

Returns

An object of class DataSim.

Examples
data <- ClusterMixture$new(n = 100, p = 2, overlap = "low")
data$gen_data()
print(data$get_x()[1:2,])

ClusterMixture$get_design()

Returns the chosen design parameters

Usage
ClusterMixture$get_design()

ClusterMixture$get_pscore()

Returns the true propensity score

Usage
ClusterMixture$get_pscore()

ClusterMixture$get_cluster()

Returns the cluster of each unit

Usage
ClusterMixture$get_cluster()

ClusterMixture$clone()

The objects of this class are cloneable with this method.

Usage
ClusterMixture$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `ClusterMixture$new()`
## ------------------------------------------------

data <- ClusterMixture$new(n = 100, p = 2, overlap = "low")
data$gen_data()
print(data$get_x()[1:2,])

causalOT documentation built on Nov. 24, 2026, 1:06 a.m.