5.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: int | None = None)[source]#
Simulate a linear VAR process of a “stationary” causal graph.
- Parameters:
- n_variablesint, optional
The number of variables to included in the final simulation, by default 5.
- p_time_selffloat, optional
The probability for an edge across time for the same variable, by default 0.5.
- p_time_varsfloat, optional
The probability for an edge across time for different variables, by default 0.5.
- p_contemporaneousfloat, 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_lagint, optional
The maximum lag allowed in the resulting process, by default 1.
- n_timesint, optional
The number of time points to generate per realization, by default 1000. See
simulate_data_from_var
for more information.- n_realizationsint, optional
The number of independent realizations, by default 1. See
simulate_data_from_var
for more information.- weight_distCallable, optional
The distribution of weights for connections, by default None.
- random_stateint, optional
The random state, by default None.
- Returns:
- dataArrayLike of shape (n_nodes, n_times * n_realizations)
The simulated data.
- var_modelStationaryTimeSeriesDiGraph 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.