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 = 0is 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
a parameter-free prediction tested by qq_test() (Wang and Busemeyer, 2013).
Classes
General projective model of two questions. |
|
Three-dimensional real quantum-like model of two questions. |
|
Four-dimensional real model in which the questions can be compatible or incompatible. |
|
Classical baseline: one order-free joint distribution. |
|
Classical baseline: the second answer is anchored on the first. |
|
Reference model with a free answer distribution per order. |
Functions
First- and second-position "yes" rates. |
|
QQ statistic. |
|
Two-sided z test of the QQ equality. |
- class ProjectiveQuestionModel(psi, projectors)[source]#
Bases:
objectGeneral 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.
- class QuantumOrderModel(**params)[source]#
Bases:
ModelThree-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:
- 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:
- class QuantumOrderModel4D(**params)[source]#
Bases:
ModelFour-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:
- 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:
- class BayesOrderModel(**params)[source]#
Bases:
ModelClassical baseline: one order-free joint distribution.
- Parameters:
- joint()[source]#
Joint distribution with A first.
- Returns:
numpy.ndarray–[yy, yn, ny, nn].
- class AnchoringOrderModel(**params)[source]#
Bases:
ModelClassical 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 forw < 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,wBis ignored andwAis used for both questions.
- class SaturatedOrderModel(**params)[source]#
Bases:
ModelReference model with a free answer distribution per order.
Six parameters (softmax logits, three per order); no model can fit the data better.
- Parameters:
- rates(pred)[source]#
First- and second-position “yes” rates.
- Parameters:
pred (
dict) –{'AB': cells, 'BA': cells}frompredictor 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:
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)