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

A proposal to make the correlated t-test less conservative #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions src/cmpbayes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,17 @@ def fit(self, random_seed=None, num_samples=10000):

x_over = x.mean()
n = len(x)
sigma_2_hat = ((x - x_over)**2).sum() / (n - 1)
rho = self.fraction_test

sigma_2_hat = ((x - x_over) ** 2).sum() / (n - 1)
corrected_sigma_2_hat = (1 / n + rho / (1 - rho)) * sigma_2_hat # Corrected variance using Nadeau-Bengio's correction
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment above the lines to keep the lines the comments refer to (to keep lines at less than 80 characters). Also, please end comments with a full stop.

scale = np.sqrt(corrected_sigma_2_hat) # Calculate the scale parameter incorporating the correlation factor

# Equation (8) from Corani and Benavoli, 2015, *A Bayesian approach for
# comparing cross-validated algorithms on multiple data sets*.
self.model_ = st.t(df=n - 1,
loc=x_over,
scale=(1 / n + rho / (1 - rho)) * sigma_2_hat)
scale=scale)
# TODO Consider splitting num_samples into chains to prevent arviz warning
self.fit_: np.ndarray = self.model_.rvs(num_samples)
self.infdata_: arviz.InferenceData = az.convert_to_inference_data(
Expand Down