Fixed indicator matrix (allpairs)
Previously allpairs indicator matrix only returned zeros (and not 1 -1
contrasts)
@@ -48,13 +48,11 @@ def allpairs(index_vector):
rows = np.size(index_vector)
indicator_matrix = np.zeros((
int(n_unique * (n_unique - 1) / 2), rows))
- n_unique = 0
- # Now man_uniquee a matriindicator_matrix with a pair of conditions per row
+ n_row = 0
+ # Now make an indicator_matrix with a pair of conditions per row
for i in range(n_unique):
for j in np.arange(i+1,n_unique):
- indicator_matrix[n_unique, index_vector == c_unique[i]] \
- = 1. / sum(index_vector == i)
- indicator_matrix[n_unique, index_vector == c_unique[j]] \
- = -1. / sum(index_vector == j) * 1.
- n_unique = n_unique + 1
+ indicator_matrix[n_row,index_vector == c_unique[i]] = 1./sum(index_vector == c_unique[i])
+ indicator_matrix[n_row,index_vector == c_unique[j]] = -1./sum(index_vector == c_unique[j])
+ n_row = n_row + 1
return indicator_matrix
