4.1.1. pywhy_graphs.simulate.simulate_linear_var_process#

pywhy_graphs.simulate.simulate_linear_var_process(n_variables: int = 5, p_time_self: float = 0.5, p_time_vars: float = 0.5, p_contemporaneous: float = 0.5, max_lag: int = 1, n_times: int = 1000, n_realizations: int = 1, weight_dist: ~typing.Callable = <scipy.stats._continuous_distns.norm_gen object>, random_state: ~typing.Optional[int] = None)[source]#

Simulate a linear VAR process of a “stationary” causal graph.

Parameters:

n_variables : int, optional

The number of variables to included in the final simulation, by default 5.

p_time_self : float, optional

The probability for an edge across time for the same variable, by default 0.5.

p_time_vars : float, optional

The probability for an edge across time for different variables, by default 0.5.

p_contemporaneous : float, optional

The probability for a contemporaneous edge among different variables, by default 0.5. Can be set to 0 to specify that the underlying causal process has no instantaneous effects.

max_lag : int, optional

The maximum lag allowed in the resulting process, by default 1.

n_times : int, optional

The number of time points to generate per realization, by default 1000. See simulate_data_from_var for more information.

n_realizations : int, optional

The number of independent realizations, by default 1. See simulate_data_from_var for more information.

weight_dist : Callable, optional

The distribution of weights for connections, by default None.

random_state : int, optional

The random state, by default None.

Returns:

data : ArrayLike of shape (n_nodes, n_times * n_realizations)

The simulated data.

var_model : StationaryTimeSeriesDiGraph of shape (n_nodes, n_nodes, max_lag)

The resulting time-series causal graph.

Notes

In stationary time-series graphs without latent confounders, there is never a worry about acyclicity among “lagged nodes” in the graph. However, if we model the situation where there are instantaenous, or contemporaneous effects, then those edges may form a cycle when simulating the graph. Therefore, if p_contemporaneous > 0, then an additional check for DAG among the contemporaneous edge network is checked.

To simulate VAR process with latent confounders (i.e. missing variable time-series), then one can simply simulate the full VAR process and then delete the simulated time-series data from the latent variable.