From 58db7caab1c1c8b6a5025cc0be8a5d799aa65515 Mon Sep 17 00:00:00 2001 From: speco29 Date: Thu, 23 Jan 2025 00:42:44 +0530 Subject: [PATCH 1/3] fixes #802 Added an entry in FAQ --- docs/faq.qmd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/faq.qmd b/docs/faq.qmd index 9f427a95..c4d4acac 100644 --- a/docs/faq.qmd +++ b/docs/faq.qmd @@ -16,6 +16,11 @@ It is a very powerful library, but can be challenging to use for beginners. Bambi provides a simple interface for specifying models, and allows for easy inference via MCMC or variational inference using PyMC. +## Why do the functions in the `interpret` submodule expect names of variables and not names of terms? + +* In the interpret submodule, functions are designed to work with the names of variables directly rather than the names of terms. This approach simplifies the usage and avoids potential confusion. + For example, instead of passing bs(var_name, degree=3, knots=knots), you should pass var_name. The term bs(var_name, degree=3, knots=knots) represents a transformed version of the variable which includes additional details like degree and knots. However, the interpret functions are built to handle the raw variable names to maintain clarity and simplicity. + ## Inference Questions ### What sampling methods are available? From d4e5d572d9448293f4ad00c5c7f7df5b1101b73a Mon Sep 17 00:00:00 2001 From: speco29 Date: Thu, 23 Jan 2025 20:17:32 +0530 Subject: [PATCH 2/3] fixes #437 Added piecewise regression example to example docs. --- examples | 1 - examples.py | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) delete mode 120000 examples create mode 100644 examples.py diff --git a/examples b/examples deleted file mode 120000 index 88458cdf..00000000 --- a/examples +++ /dev/null @@ -1 +0,0 @@ -docs/notebooks \ No newline at end of file diff --git a/examples.py b/examples.py new file mode 100644 index 00000000..ee2b7b27 --- /dev/null +++ b/examples.py @@ -0,0 +1,21 @@ +# piecewise_regression_example +import pandas as pd +import statsmodels.formula.api as smf + +# Example data +data = pd.DataFrame({ + 'x': range(30), + 'response': [i + (i >= 10) * 5 + (i >= 20) * 10 for i in range(30)] +}) + +# Piecewise function +def truncate(x, l): + x = (x - l) * (x >= l) + return x + +# Piecewise regression formula +formula = "response ~ x + truncate(x, 10) + truncate(x, 20)" + +# Fit the model +model = smf.ols(formula=formula, data=data).fit() +print(model.summary()) From 3fbc8d98d0af38ae425426dbdf35dcefc9944bf6 Mon Sep 17 00:00:00 2001 From: specsy Date: Thu, 23 Jan 2025 20:22:07 +0530 Subject: [PATCH 3/3] Delete examples.py --- examples.py | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 examples.py diff --git a/examples.py b/examples.py deleted file mode 100644 index ee2b7b27..00000000 --- a/examples.py +++ /dev/null @@ -1,21 +0,0 @@ -# piecewise_regression_example -import pandas as pd -import statsmodels.formula.api as smf - -# Example data -data = pd.DataFrame({ - 'x': range(30), - 'response': [i + (i >= 10) * 5 + (i >= 20) * 10 for i in range(30)] -}) - -# Piecewise function -def truncate(x, l): - x = (x - l) * (x >= l) - return x - -# Piecewise regression formula -formula = "response ~ x + truncate(x, 10) + truncate(x, 20)" - -# Fit the model -model = smf.ols(formula=formula, data=data).fit() -print(model.summary())