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

[FIX] Refactor design matrix and contrast formula for the two-sample T-test example #4407

Merged
merged 16 commits into from
May 27, 2024
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,20 @@
# Next, we model the effect of conditions (sample 1 vs sample 2).
import numpy as np

condition_effect = np.hstack(([1] * n_subjects, [-1] * n_subjects))
condition_effect = np.hstack(([1] * n_subjects, [0] * n_subjects))

# %%
# The design matrix for the unpaired test doesn't need any more columns
# The design matrix for the unpaired test needs to add an intercept,
# For the paired test, we include an intercept for each subject.
subject_effect = np.vstack((np.eye(n_subjects), np.eye(n_subjects)))
subjects = [f"S{i:02d}" for i in range(1, n_subjects + 1)]

# %%
# We then assemble those into design matrices
unpaired_design_matrix = pd.DataFrame(
condition_effect[:, np.newaxis], columns=["vertical vs horizontal"]
unpaired_design_matrix = pd.DataFrame({
Remi-Gau marked this conversation as resolved.
Show resolved Hide resolved
"vertical vs horizontal": condition_effect,
"intercept": 1,
}
)

paired_design_matrix = pd.DataFrame(
Expand Down