nl_causal.base

Package Contents

Classes

neg_log_uniform

negative log uniform distribution

Functions

calculate_vif_(X[,Ā thresh,Ā verbose,Ā method])

Remove multicollinearity features.

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

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

nl_causal.base.calculate_vif_(X, thresh=2.5, verbose=0, method='best')

Remove multicollinearity features.

Parameters:
X: {array-like, sparse matrix} of shape (n_samples, n_features)

Feature matrix

Returns:
X: return feature matrix by removing multicollinearity features.
class nl_causal.base.neg_log_uniform(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, seed=None)

Bases: scipy.stats.rv_continuous

negative log uniform distribution

_cdf(x)

cdf of the negative log uniform distribution

nl_causal.base.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