Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Returns
-------
amce : array of shape (N,)
Average Mediated Causal Effect.
"""
amce = np.zeros(self.N)
for k in range(self.N):
amce[k] = self.get_amce(k,
lag_mode=lag_mode,
exclude_k=exclude_k,
exclude_self_effects=exclude_self_effects)
return amce
class Prediction(Models, PCMCI):
r"""Prediction class for time series models.
Allows to fit and predict from any sklearn model. The optimal predictors can
be estimated using PCMCI. Also takes care of missing values, masking and
preprocessing.
Parameters
----------
dataframe : data object
Tigramite dataframe object. It must have the attributes dataframe.values
yielding a numpy array of shape (observations T, variables N) and
optionally a mask of the same shape and a missing values flag.
train_indices : array-like
Either boolean array or time indices marking the training data.
Returns
-------
coeffs : dictionary
Dictionary of dictionaries for each variable with keys given by the
parents and the regression coefficients as values.
"""
coeffs = {}
for j in self.selected_variables:
coeffs[j] = {}
for ipar, par in enumerate(self.all_parents[j]):
coeffs[j][par] = self.fit_results[j]['model'].coef_[ipar]
return coeffs
class LinearMediation(Models):
r"""Linear mediation analysis for time series models.
Fits linear model to parents and provides functions to return measures such
as causal effect, mediated causal effect, average causal effect, etc. as
described in [4]_.
Notes
-----
This class implements the following causal mediation measures introduced in
[4]_:
* causal effect (CE)
* mediated causal effect (MCE)
* average causal effect (ACE)
* average causal susceptibility (ACS)
* average mediated causal effect (AMCE)