nl_causal.base.sim_data

Module Contents

Functions

sim(n, p, theta0, beta0[, alpha0, case, feat, IoR])

Simulate data for the nonlinear causal IV model (see [1]).

sim_phi(X[, case])

Apply a transformation to the input based on the specified case.

print_msg_box(msg[, indent, width, title])

Print message-box with optional title.

nl_causal.base.sim_data.sim(n, p, theta0, beta0, alpha0=0.0, case='log', feat='normal', IoR=None)

Simulate data for the nonlinear causal IV model (see [1]).

Parameters:
nint

Number of samples.

pint

Number of features (IVs).

theta0array_like

True coefficients for the IVs to exposure.

beta0float

True coefficient for the causal effect from exposure to outcome.

alpha0float, optional

True coefficients for invalid IVs (default is 0.).

casestr, optional

Type of nonlinear causal transformation (‘linear’, ‘log’, ‘cube-root’, ‘inverse’, ‘sigmoid’, ‘piecewise_linear’), (default is ‘log’).

featstr, optional

Type of feature distribution (‘normal’, ‘AP-normal’, ‘laplace’, ‘uniform’, ‘cate’). (default is ‘normal’).

IoRarray_like or None, optional

The region of interest (default is None): checking the nonlinear causal transformation.

Returns:
Z{array-like} of shape (n, p)

n simluated data of IVs.

X{array-like} of shape (n, )

n simluated data of exposure.

y{array-like} of shape (n, )

n simluated data of outcome.

phi{array-like} of shape (n, )

transformed exposure based on the transformation case.

phi_ior{array-like} of shape (n, ) (if IoR is not None)

transformed region of intere (IoR) based on the transformation case.

References

nl_causal.base.sim_data.sim_phi(X, case='linear')

Apply a transformation to the input based on the specified case.

Parameters:
Xarray_like

Input data to be transformed.

casestr, optional

Type of transformation to be applied (default is ‘linear’). Supported cases are: ‘linear’, ‘log’, ‘cube-root’, ‘inverse’, ‘sigmoid’, and ‘piecewise_linear’.

Returns:
array_like

The transformed data based on the specified case.

nl_causal.base.sim_data.print_msg_box(msg, indent=1, width=None, title=None)

Print message-box with optional title.