Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug in causal effects #202

Merged
merged 1 commit into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run(self):
# Run the setup
setup(
name="tigramite",
version="5.0.1.7",
version="5.0.1.8",
packages=["tigramite", "tigramite.independence_tests", "tigramite.toymodels"],
license="GNU General Public License v3.0",
description="Tigramite causal discovery for time series",
Expand Down
37 changes: 19 additions & 18 deletions tigramite/causal_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2367,6 +2367,9 @@ def fit_bootstrap_of(self, method, method_args,
getattr(self, method)(**method_args_bootstrap)
self.bootstrap_results[b] = deepcopy(self.model)

# Reset model
self.model = self.original_model

return self


Expand Down Expand Up @@ -2552,44 +2555,42 @@ def lin_f(x): return x
# print(causal_effects.get_optimal_set())

# # Fit causal effect model from observational data
causal_effects.fit_wright_effect(
causal_effects.fit_total_effect(
dataframe=dataframe,
# mask_type='y',
# estimator=LinearRegression(),
estimator=LinearRegression(),
)


# # Fit causal effect model from observational data
causal_effects.fit_bootstrap_of(
method='fit_total_effect',
method_args={'dataframe':dataframe,
# mask_type='y',
'estimator':LinearRegression()
},
seed=4
)


# Predict effect of interventions do(X=0.), ..., do(X=1.) in one go
dox_vals = np.array([1.]) #np.linspace(0., 1., 1)
intervention_data = dox_vals.reshape(len(dox_vals), len(X))
pred_Y = causal_effects.predict_wright_effect(
pred_Y = causal_effects.predict_total_effect(
intervention_data=intervention_data)
print(pred_Y)


# # Fit causal effect model from observational data
causal_effects.fit_bootstrap_of(
method='fit_wright_effect',
method_args={'dataframe':dataframe,
# mask_type='y',
# 'estimator':LinearRegression()
}
)


# Predict effect of interventions do(X=0.), ..., do(X=1.) in one go
dox_vals = np.array([1.]) #np.linspace(0., 1., 1)
intervention_data = dox_vals.reshape(len(dox_vals), len(X))
conf = causal_effects.predict_bootstrap_of(
method='predict_wright_effect',
method='predict_total_effect',
method_args={'intervention_data':intervention_data})
print(conf)

# # Predict effect of interventions do(X=0.), ..., do(X=1.) in one go
dox_vals = np.array([1.]) #np.linspace(0., 1., 1)
intervention_data = dox_vals.reshape(len(dox_vals), len(X))
pred_Y = causal_effects.predict_wright_effect(
intervention_data=intervention_data)
print(pred_Y)


# # Predict effect of interventions do(X=0.), ..., do(X=1.) in one go
Expand Down