Simulation code — spycause 0.1 documentation

# Simulation code

[add text here]

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

    Initialize self and parameters for simulation.

    ## Parameters

    Nlat: int

      side length of the lattice

    D: int

      number of covariates to generate

    sp_confound: matrix, default None

      matrix specifying the mode of confounding between locations

    interference: matrix, 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

    treatfloat, 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)