CBAS Correlative Mode

When you don't have discrete groups, but a continuous measure per subject.

0 When to Use Correlative Mode

Part 1 of this walkthrough covers comparative mode, where you split subjects into two groups (like "control" and "lesion") and look for behavioral patterns that differ between them.

But what if you don't have two groups? What if instead, each subject has a score on some continuous scale? For example:

In these cases, there's no natural way to split subjects into "group A" and "group B." Instead, you want to ask: "Are any behavioral patterns produced more (or less) by subjects who score higher on this measure?"

That's what correlative mode does. It looks for sequences whose usage correlates with the continuous variable.

Comparative mode (Part 1)

Input: subjects in 2 groups

Question: which patterns differ between groups?

Measures: difference in group averages

Null: shuffle group labels

Correlative mode (this page)

Input: each subject has a score

Question: which patterns track with the score?

Measures: correlation between count and score

Null: shuffle the scores across subjects

The counting step (step 1 from Part 1) is exactly the same. You still slide a window across each subject's choice stream and build a count matrix. The differences start at step 2, where you measure the strength of the relationship.

The big picture

Here's what the full setup looks like. Each subject has a choice stream (just like Part 1) AND a continuous score. After counting sequences, you get a matrix. Then for each sequence (each column), you ask: "Does usage of this sequence track with the score across subjects?"

On the left, each row is a subject. You can see their choice stream and their score. In the middle, the count matrix tallies how often each subject produced each sequence. On the right, picking one column (one sequence) and pairing it with the scores gives you a scatter plot. The correlation across that scatter is a single number that measures how strongly that sequence tracks with the covariate.

CBAS repeats this for every column (every sequence), producing one test statistic per sequence. Then it asks: which of those are strong enough to survive correction for all the tests you just ran?

1 What is Correlation?

Before diving into formulas, let's build intuition for what correlation means visually.

Imagine you have 50 subjects. Each subject produced some sequence (say "LRL") a certain number of times. You also have a clinical score for each subject. If you plot one against the other, you get a scatter plot. Each dot is one subject.

r = 0.60

Try it: Drag "correlation strength" to the right. The dots line up more. Subjects who produce this sequence more also tend to have higher scores. That's a positive correlation.

Now drag it to the left (negative). The relationship flips: subjects who produce the sequence more tend to have lower scores.

Now increase "noise." Even with a real underlying relationship, individual subjects scatter widely. With enough noise, you can't tell if the trend is real or just random variation. This is why you need a statistical test, not just eyeballing.

From a cloud of dots to a single number

The correlation coefficient (r, also called rho) collapses the entire scatter plot into one number between -1 and +1:

It works by asking, for each subject: "Are you above or below average on both measures, or above on one and below on the other?" If most subjects are consistently above-or-below on both, r is positive. If they tend to be high on one and low on the other, r is negative.

2 From Correlation to a Test Statistic

A correlation of r = 0.3 could be meaningful or meaningless depending on how many subjects you have and how noisy the data is.

With 10 subjects, an r of 0.3 could easily happen by chance. With 1,000 subjects, an r of 0.3 almost certainly reflects a real relationship. You need to account for this.

The signal-to-noise ratio (same idea as Part 1)

In comparative mode, the test statistic was: (group difference) / (uncertainty in that difference). The bigger the difference relative to the noise, the more confident you are.

In correlative mode, the same idea applies:

t = √n × r / τ Take the correlation (r), scale it up by the square root of the sample size, and divide by a measure of how variable the correlation estimate is (τ).

Why each piece matters

√n: More subjects means more evidence. An r of 0.2 with 400 subjects (t = 20 × 0.2 / τ) is much more convincing than with 16 subjects (t = 4 × 0.2 / τ).

r (the correlation): A stronger linear relationship gives a bigger t.

τ (tau, the denominator): This measures how stable the correlation estimate is. If some subjects are extreme outliers that heavily influence r, τ will be large, and t will shrink. This makes the test robust to non-normal data.

This bar shows the t-value from the scatter plot above. Blue means positive correlation, pink means negative. As you make the correlation stronger or reduce noise, t grows. A larger t means more evidence that the relationship is real.

The same two-sided approach

Just like in Part 1, CBAS tests each direction separately. For a given sequence, if the correlation is positive, the t-value goes in the "positive" slot. If negative, it goes in the "negative" slot. This doubles the number of tests but cleanly separates the two questions ("does more of this sequence go with higher scores?" vs "does more go with lower scores?").

3 What Would Chance Look Like?

You found a t-value of 3.5 for some sequence. Is that big enough to be real, or could it happen by random chance when you're testing hundreds of sequences?

To answer this, you need to know what t-values look like when there is no real relationship. In Part 1, you built this "null distribution" by shuffling group labels. Here, you build it by shuffling the scores.

The permutation trick

Here's the key idea. You keep every subject's behavioral sequence counts exactly as they are. You keep all the scores in the pool. But you randomly reassign which subject gets which score. Subject A keeps their choice stream but gets subject C's clinical score. Subject B keeps their choices but gets subject A's score. And so on.

After this shuffling, any correlation between behavior and scores is destroyed, because the pairing is now random. If you recompute the correlation, you get a number that reflects pure noise.

Do this 10,000 times and you learn what noise looks like.

0 / 10,000

Left panel: the scatter plot. Click "Permute once" and watch the y-values (scores) jump to random x-positions. The trend line flattens because the pairing is now random.

Right panel: the t-value from each permutation gets added to a histogram. After many permutations, you can see the full distribution of what "no real relationship" produces. The red dashed line is your real observed t. If it's far to the right of the null histogram, the relationship is unlikely to be chance.

Why shuffle scores instead of reshuffling subjects into fake groups (like Part 1)? Because there are no groups here. The permutation breaks the link between behavior and the continuous measure while preserving the distribution of both. Every score stays in the pool, every subject's behavior stays intact, only the pairing changes.

Same matrix, same downstream steps

After 10,000 permutations, you have a null matrix just like in Part 1: 10,000 rows (one per permutation) and one column per sequence being tested. From here, the step-down procedure and k-FWER iteration work identically. If you haven't read those yet, see steps 4 and 5 in Part 1.

4 What Significant Results Mean

When CBAS declares a sequence significant in correlative mode, it means:

"Subjects who produce this behavioral pattern more (or less) tend to score higher (or lower) on the covariate, and this relationship is stronger than what 10,000 random score-reassignments would produce, even after correcting for the fact that hundreds of sequences were tested simultaneously."

That's a strong claim. It survived both the multiple-testing correction (step-down) and the false discovery proportion control (k-FWER).

A concrete example

In the human dataset, 1,413 subjects performed a 6-armed bandit task. Each subject has a CBIT score measuring cognitive flexibility. CBAS tested 408 sequences (length 2 through 4) and found 31 that significantly correlate with CBIT, at k=2.

Some of these sequences correlate positively: subjects with higher cognitive flexibility produce them more. Others correlate negatively: flexible subjects produce them less. Together, they reveal the specific choice structures that characterize flexible decision-making.

Direction matters

The output always tells you the direction. "Sequence LRL is positively correlated with CBIT" means subjects with higher flexibility scores tend to use that pattern more. "Sequence RRR is negatively correlated" means flexible subjects use it less. You get this information for every significant sequence.

What's the same, what's different

To summarize the relationship between the two modes:

Once the null matrix exists, the algorithm doesn't know or care which mode produced it. Everything downstream is mode-agnostic.

← Part 1: Comparative Mode