Order effects#

Question-order effects: two yes/no questions A and B asked in either order.

Design. Conditions 'AB' (A asked first) and 'BA' (B asked first). The outcomes of each condition are the four answer pairs [yy, yn, ny, nn], where the first letter is the answer to the question asked first.

Models.

  • QuantumOrderModel: three-dimensional real quantum-like model (Lüders rule), with the rank (1 or 2) of each question’s “yes” subspace as a structural option; three parameters; satisfies the QQ equality.

  • QuantumOrderModel4D: four-dimensional model with an incompatibility angle; phi = 0 is exactly the Bayesian model, so it nests it (four parameters). Recommended default.

  • BayesOrderModel: one order-free joint distribution (no order effect).

  • AnchoringOrderModel: the second answer is pulled toward (w > 0) or away from (w < 0) the first, with a weight per question; violates the QQ equality when the weights differ.

  • SaturatedOrderModel: a free distribution per order (6 parameters; reference only).

  • ProjectiveQuestionModel: any state and any projectors in any dimension (not fitted).

QQ equality. Every projective model satisfies

\[p_{AB}(yn) + p_{AB}(ny) = p_{BA}(yn) + p_{BA}(ny),\]

a parameter-free prediction tested by qq_test() (Wang and Busemeyer, 2013).

Classes

ProjectiveQuestionModel

General projective model of two questions.

QuantumOrderModel

Three-dimensional real quantum-like model of two questions.

QuantumOrderModel4D

Four-dimensional real model in which the questions can be compatible or incompatible.

BayesOrderModel

Classical baseline: one order-free joint distribution.

AnchoringOrderModel

Classical baseline: the second answer is anchored on the first.

SaturatedOrderModel

Reference model with a free answer distribution per order.

Functions

rates

First- and second-position "yes" rates.

qq_statistic

QQ statistic.

qq_test

Two-sided z test of the QQ equality.

class ProjectiveQuestionModel(psi, projectors)[source]#

Bases: object

General projective model of two questions.

Parameters:
  • psi (array_like) – Belief state (real or complex); normalised on construction.

  • projectors (dict) – {'A': P_A, 'B': P_B}: projectors of the “yes” answers.

answer_probs(order)[source]#

Probabilities of all answer sequences.

Parameters:

order (sequence of str) – Questions in the order they are asked, for example ('A', 'B').

Returns:

dict – {(a1, a2): probability} from the Lüders rule.

predict(design=None)[source]#

Answer distribution for each question order.

Parameters:

design (sequence of str, optional) – Orders, default ('AB', 'BA').

Returns:

dict – {order: [yy, yn, ny, nn]}.

class QuantumOrderModel(**params)[source]#

Bases: Model

Three-dimensional real quantum-like model of two questions.

The belief state is \(\psi = e_1\); the questions are defined by the unit vectors \(u_A = (\cos a, \sin a, 0)\) and \(u_B = (\cos b, \sin b \cos g, \sin b \sin g)\).

Parameters:
  • a (float) – Angles (fitted).

  • b (float) – Angles (fitted).

  • g (float) – Angles (fitted).

  • ranks (tuple of int, optional) – (rA, rB). Rank 1: “yes” is the ray of \(u_q\); rank 2: the plane orthogonal to \(u_q\). Default (1, 1); fit all four with structures=RANK_STRUCTURES.

vectors()[source]#

Unit vectors that define the two questions.

Returns:

dict – {'A': u_A, 'B': u_B}.

projectors()[source]#

Projectors of the “yes” answers.

Returns:

dict – {'A': P_A, 'B': P_B}, 3 x 3 matrices of rank 1 or 2.

as_projective()[source]#

The same model as a ProjectiveQuestionModel.

Returns:

ProjectiveQuestionModel

predict(design=None)[source]#

Answer distribution [yy, yn, ny, nn] for each order (default 'AB', 'BA').

class QuantumOrderModel4D(**params)[source]#

Bases: Model

Four-dimensional real model in which the questions can be compatible or incompatible.

The basis \(e_1, \dots, e_4\) is (yes, yes), (yes, no), (no, yes), (no, no) of a classical 2 x 2 table, and \(P_A = \mathrm{span}(e_1, e_2)\). \(P_B = U\,\mathrm{span}(e_1, e_3)\,U^T\), where \(U\) rotates by the incompatibility angle \(\varphi\) in the planes \((e_1, e_4)\) and \((e_2, e_3)\).

With \(\varphi = 0\) the projectors commute and the model is exactly the order-free Bayesian model (\(\psi_k^2\) is the joint table), so it nests BayesOrderModel; \(\varphi \neq 0\) produces order effects, and the QQ equality still holds.

Parameters:
  • t1 (float) – Hyperspherical angles of the state \(\psi\).

  • t2 (float) – Hyperspherical angles of the state \(\psi\).

  • t3 (float) – Hyperspherical angles of the state \(\psi\).

  • phi (float) – Incompatibility angle.

projectors()[source]#

Projectors of the “yes” answers.

Returns:

dict – {'A': P_A, 'B': P_B}, 4 x 4 matrices of rank 2.

as_projective()[source]#

The same model as a ProjectiveQuestionModel.

Returns:

ProjectiveQuestionModel

predict(design=None)[source]#

Answer distribution [yy, yn, ny, nn] for each order (default 'AB', 'BA').

class BayesOrderModel(**params)[source]#

Bases: Model

Classical baseline: one order-free joint distribution.

Parameters:
  • pA (float) – Marginal “yes” probabilities.

  • pB (float) – Marginal “yes” probabilities.

  • rho (float) – Correlation in (-1, 1), scaled between the bounds that the marginals allow.

joint()[source]#

Joint distribution with A first.

Returns:

numpy.ndarray – [yy, yn, ny, nn].

predict(design=None)[source]#

Answer distribution for each order; the BA order swaps the yn and ny cells.

class AnchoringOrderModel(**params)[source]#

Bases: Model

Classical baseline: the second answer is anchored on the first.

The first answer is given at its first-position rate. For w >= 0, P(second yes | first yes) = p2 + w (1 - p2) and P(second yes | first no) = p2 (1 - w); the mirror image applies for w < 0.

Parameters:
  • pA (float) – “Yes” rates of each question when asked first.

  • pB (float) – “Yes” rates of each question when asked first.

  • wA (float) – Anchoring weight when A (respectively B) is the second question, in (-0.99, 0.99).

  • wB (float) – Anchoring weight when A (respectively B) is the second question, in (-0.99, 0.99).

  • tied (bool, optional) – If True, wB is ignored and wA is used for both questions.

predict(design=None)[source]#

Answer distribution [yy, yn, ny, nn] for each order.

class SaturatedOrderModel(**params)[source]#

Bases: Model

Reference model with a free answer distribution per order.

Six parameters (softmax logits, three per order); no model can fit the data better.

Parameters:
  • x0 (float) – Logits of yy, yn, ny (relative to nn) for AB, then for BA.

  • ... (float) – Logits of yy, yn, ny (relative to nn) for AB, then for BA.

  • x5 (float) – Logits of yy, yn, ny (relative to nn) for AB, then for BA.

predict(design=None)[source]#

Answer distribution for each order (softmax of the logits).

rates(pred)[source]#

First- and second-position “yes” rates.

Parameters:

pred (dict) – {'AB': cells, 'BA': cells} from predict or from data proportions.

Returns:

numpy.ndarray – [A first, B first, A second, B second].

qq_statistic(cells_ab, cells_ba)[source]#

QQ statistic.

Parameters:
  • cells_ab (array_like) – [yy, yn, ny, nn] probabilities for each order.

  • cells_ba (array_like) – [yy, yn, ny, nn] probabilities for each order.

Returns:

float – \([p_{AB}(yn) + p_{AB}(ny)] - [p_{BA}(yn) + p_{BA}(ny)]\); zero for every projective model.

qq_test(counts)[source]#

Two-sided z test of the QQ equality.

Parameters:

counts (dict) – {'AB': [yy, yn, ny, nn], 'BA': [...]} answer counts.

Returns:

  • q (float) – Observed QQ statistic.

  • z (float) – z score.

  • p_value (float) – Two-sided p-value; a small value rejects every projective (quantum-like) model.

Examples

>>> from quantum_mind.families.order_effects import qq_test
>>> q, z, p = qq_test({'AB': [40, 10, 10, 40], 'BA': [40, 10, 10, 40]})
>>> q, p
(0.0, 1.0)