Simulation code

[add text here]

class spycause.simulator.CARSimulator(Nlat, D, sp_confound=None, interference=None)
__init__(Nlat, D, sp_confound=None, interference=None)

Template class for data simulation. Provides initialization for input parameters and prescribes base functionality.

Nlatint

side length of the lattice

Dint

number of covariates to generate

sp_confoundmatrix, default None

matrix specifying the mode of confounding between locations

interferencematrix, string, or int, default None

matrix specifying the mode of interference between locations string options: - “general”: interference between all locations - “partial”: interference only among locations in clusters

generated using RandomRegion. Recommended to select the clusters yourself and manually input the adjacency matrix (block diagonal) as the RandomRegion call takes a while. If int, then generates that number of clusters.

  • “network”: interference among adjacent locations using Queen weights

  • “none”: no interference, same as passing None

simulate(treat=0.5, z_conf=0.25, y_conf=0.5, interf=0, x_sd=1, x_sp=0.9, ucar_sd=2, ucar_str=0.95, vcar_sd=2, vcar_str=0.95, balance=0.5, y_sd=0.1, **kwargs)

Simulate data based on some parameters. All the conf and interf parameters could be arrays of size D if different variables have different levels of confounding or interference.

Parameters treat : float, default 0.5

treatment effect of Z on Y

z_conffloat, default 0.25

effect of nonspatial confounding on Z

y_conffloat, default 0.5

effect of nonspatial confounding on Y

interffloat, default 0

effect of interference on Y

x_sdfloat, default 1

standard deviation of confounders

x_spfloat, default 0.9

spatial autocorrelation parameter

y_sdfloat, default 0.1

SD of nonspatial error term on Y

ucar_sdfloat, default 2

SD of CAR term for confounding on Y

vcar_sdfloat, default 2

SD of CAR term for confounding on Z

ucar_strfloat, default 0.95

strength of spatial association for confounding on Y

vcar_strfloat, default 0.95

strength of spatial association for confounding on Z

balancefloat, default 0.5

balancing factor that parametrizes the shared spatial confounding between Y and Z

Returns X : covariates (NxD) Y : outcomes (Nx1) Z : treatment (Nx1)