causalcompass.datasets.mixed_data.generate_mixed_var

causalcompass.datasets.mixed_data.generate_mixed_var(p, T, lag=3, sparsity=0.2, beta_value=1.0, sd=0.1, burn_in=100, typeflag=None, discrete_ratio=0.5, seed=0, length_per_batch=50, device=torch.device('cuda:0'))[source]

Generate VAR data where a proportion of variables are discretized.

References

https://github.com/chunhuiz/MiTCD

Parameters:
  • p (int) – Number of variables

  • T (int) – Number of time points

  • lag (int, default 3) – Number of lags in the VAR model

  • sparsity (float, default 0.2) – Sparsity of the causal graph

  • beta_value (float, default 1.0) – Coefficient value

  • sd (float, default 0.1) – Noise standard deviation

  • burn_in (int, default 100) – Burn-in period

  • typeflag (list or None, default None) – Manual specification of variable types (0=discrete, 1=continuous). If None, automatically generated based on discrete_ratio

  • discrete_ratio (float, default 0.5) – Ratio of discrete variables

  • seed (int, default 0) – Random seed

  • length_per_batch (int, default 50) – Length of each batch for instance normalization

  • device (torch.device, default torch.device('cuda:0')) – Device for tensor computation

Returns:

(data_bin_global, data_bin_inst, GC) — globally binarized time series of shape (T, p), instance-normalized and binarized time series of shape (num_batches, length_per_batch, p), and ground-truth causal graph of shape (p, p). data_bin_inst is used as input for the MiTCD algorithm, while all other algorithms use data_bin_global as input.

Return type:

tuple