Back to How-to

Nesting

Assume that your experiment has a number of independent variables, and every condition in the experiment is defined by its combination of values on each independent variable. Nesting is a standard method of ordering the conditions according to their combination of values of independent variables (or levels of factors, in slightly different (e.g., SPSS) terminology).

Say you have three factors, A, B, and C. A and B have two levels, C has three. If you wrote a function like this:

condition = 1
for A = 1 to 2
	for B = 1 to 2
		for C = 1 to 3
			print condition A B C
			condition = condition + 1
		end
	end
end
You'd see a list appear like this (adding some imaginary formatting):

Condition 1: A = 1, B = 1, C = 1
Condition 2: A = 1, B = 1, C = 2
Condition 3: A = 1, B = 1, C = 3
Condition 4: A = 1, B = 2, C = 1
Condition 5: A = 1, B = 2, C = 2
Condition 6: A = 1, B = 2, C = 3
Condition 7: A = 2, B = 1, C = 1
Condition 8: A = 2, B = 1, C = 2
Condition 9: A = 2, B = 1, C = 3
Condition 10: A = 2, B = 2, C = 1
Condition 11: A = 2, B = 2, C = 2
Condition 12: A = 2, B = 2, C = 3

This is called "nesting C in B in A", or A is the highest level, B the second level, and C the third. Note the structure of the factor levels. As the condition index increments, factor C loops through its factor levels each time. The level of factor B only increases every time C has gone through a loop. Factor A only increases once factor B has gone through a loop.

Alternatively to the pseudocode representation of nesting, you can draw a tree diagram with A on the top, with two branches for its levels; then factor B's two branches at the ends of each of A's branches; and then factor C's three branches at the end of each of those branches. Reading off the ends of those branches from left to right gives you the condition number.

The point of this is that if you organize (usually within-subject) data in columns, where the m-th column represents the data from condition m according to a specified nesting structure, statistical software such as SPSS can use this information to know what each column represents.