bayespecon.dgp.simulate_sar

bayespecon.dgp.simulate_sar(n=None, W=None, gdf=None, rho=0.5, beta=None, sigma=1.0, err_hetero=False, rng=None, seed=None, contiguity='queen', create_gdf=False, geometry_type='polygon')[source]

Simulate data from SAR DGP y = (I-rho W)^(-1)(X beta + eps).

Parameters:
n : int, optional

Square-grid side length used when only n is supplied. This generates n * n observations on an n x n rook grid. When W or gdf is provided, n (if provided) must match the implied number of observations.

W : Graph or sparse/dense matrix, optional

Spatial weights. If supplied, takes precedence over gdf.

gdf : geopandas.GeoDataFrame, optional

Spatial units source used when W is not provided.

rho : float, default=0.5

Spatial autoregressive coefficient.

beta : np.ndarray, optional

Regression coefficients including intercept.

sigma : float, default=1.0

Innovation standard deviation.

err_hetero : bool, default=False

If True, generate heteroskedastic innovations with observation-specific standard deviations \(\sigma_i = \sigma \sqrt{1 + \|x_i\|^2}\).

rng : np.random.Generator, optional

Random generator.

seed : int, optional

Seed used when rng is not supplied.

contiguity : str, default="queen"

Neighbor rule for gdf mode.

create_gdf : bool, default=False

If True, include a gdf key in the returned dict with y and X_* columns attached to geometry.

geometry_type : {"point", "polygon"}, default="polygon"

Geometry type to generate when create_gdf=True and gdf is not provided.

Returns:

Keys: y, X, W_dense, W_graph, params_true.

Return type:

dict