NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

Try It in NetLogo Web


The q-voter model with independence [3] is a model of opinion dynamics in which each agent verbalizes an opinion on a two-point scale, such as yes/no or for/against. There are two types of social responses in the model, conformity and independence.
Conformism, which means yielding to the influence of others and adopting their opinions, was introduced in line with the results of the classic Asch experiment, which showed that by far the strongest group influence occurs when the group is unanimous [1]. Independence, on the other hand, involves not taking into account the opinions of others. The model was proposed by physicists and it resembles the famous Ising model.


We consider a population of agents on a network of size N. In this implementation we use Watts-Strogatz network, which is described by two parameters: k (the average degree of the node) and beta (probablity of rewiring). Each agent can be in one of two states +1 or -1 (e.g. opinion for or against a given issue), which is marked in green or red, respectively. There are two parameters of the model: q (the size of the influence group) and p (probability of independent behavior). Time evolution of the systems is given by the following ALGORITHM:
0) Set parameters of the network and the model, as well as the initial conditions; set counter time = 0
1) Randomly choose an agent, from all N agents, who reconsiders its opinion, we call it "target" and update counter time = time + 1
2) With probability p target behaves independently, so it does not take into account opinions of others and randomly (with probability 1/2) changes opinion to the oposite one
3) With complementary probability (1-p) it is susceptible to influence exerted by its neighbors (agents that are directly linked to the target). In such a case it randomly chooses q among all its neighborsl. If all of them have the same opinion, the target conforms and takes the opinion of the group
4) Go to 1



The model is implemented on the Watts-Strogatz network, therefore first choose parameters of the network:

* N - number of agents
* k - the average degree of the node (note that k should be an even number; in the case of odd number the average degree will be k-1; for complete graph, choose k = N - 1)
* beta - probablity of rewiring


Choose parameters of the model:

* q - size of the influence group
* p - the probability of independence


The last thing to choose is the initial fraction of agents with positive opinion, with is given by parameter:

* density_of_greens - the fraction of greens (positive opinions) at the beginning of simulations; greens are randomly distributed over the whole system.

After choosing values of all parameters click:
1) "setup" - to set all values of parematers (step 0 of the ALGORITHM described in Section HOW IT WORKS)
2) "go" - to see the evolution of the system within single update (steps 1-3 of the ALGORITHM described in Section HOW IT WORKS)
3) "go forever" - to run the model according to steps 1-4 of the ALGORITHM described in Section HOW IT WORKS

Algorithm can be also observed in the step-by-step section by clicking one by one the following buttons:
1) "target" - an agent, which opinion will be updated is selected. Thick black lines indicate the target's neighbors.
2) "q-panel" - q agents among all target's neighbors are randomply selected, they are marked with X
3) "update" - target updates it opinion according to the ALGORITHM described in Section HOW IT WORKS
The monitor displays which behavior worked - conformity or independence.


The society described by the model can be in one of two qualitatively different phases:
1) Agreement: there is a majority opinion in society, which means, for example, that in the case of democratic elections there is a clear winner; in physics we would call such a phase "ordered"
2) Disagreement: fraction of both opinions is almost equal, which means, for example, that in the case of democratic elections there is no clear winner; in physics we would call such a phase "disordered"

If we change only the independence parameter p, and keep all others fixed, we can see observe phase transition between these phases. The character of this transition depends on parameter q (size of the influence group).

For q < 6, depending on p system will be in one of these states. Disagreement is observed for p > p*, above critical point p<sup>*</sup>. In the case of agreement, for p < p*, system randomly chooses the dominating opinion. In the case of systems of finite size (as the one that we can observe here) the majority opinion may change in time - system switches between two states symmetric with respect to c = 0.5 and in the result on the histogram there are clearly two peaks.

For q >= 6 there is such a range of p, p*<sub>low</sub> < p < p*<sub>high</sub> that both qualitatively different states - agreement and disagreement coexist. The state of the system depends on the initial conditions, what we call hysteresis. However, again for the finite systems there are possible switches between these states, what can be noticed on the histogram. If the system evolves long enough, three peaks occur.


* What happens for low / high probability of independence? How the histogram changes?
For this choose e.g. complete graph of size N = 101, k = 100 and set q = 2. Run the model with different values of probability of independence: p = 0, p = 0.2, p = 0.4.
Note, how concentrations of opinions change.
Try different initial conditions.

* How frequency of switches vary with the size of the network?
Run the same experiment with p = 0.2, but for smaller network e.g. N = 75, N = 51.
Observe, how the concetrations change in time.
The smaller system, the bigger fluctations and the switches between symmetric states are more frequent.

* Hysteresis - dependence on the initial conditions
Set the following paramters N = 101, k = 100, q = 9, p = 0.07.
Run the model starting from different initial concentrations of greens: 0%, 50%, 100%.
How the final state depends on the initial one? Note that still switches between agreement and disagreement may occure.

* Coexistence of agreement and disagreement
Decrease system size to N = 51 (and set k = 50).
Run the model for p = 0.04, p = 0.06, p = 0.07, p = 0.10.
Observe the shape of a histogram.
* For p = 0.04 there is one peak close to 0 or 1 (or if one waits long enough, second symmetric peak occurs).
* For p = 0.06 there are is peak in the middle (around 0.5) and again either one or two peaks on the side.
* For p = 0.07 histogram looks simmilar, however now the middle peak becomes higher, which means that the system spends longer time in the disagreement (disordered state).
* For p = 0.10 only the middle peak remains.

Note that in order to observe meaningful histograms the system needs some time to evolve. We recommend to wait at least 100 000 ticks, however 1 000 000 would be even better.


One can extend the model by replacing independence with anticonformity or including both of these nonconformity behaviors at once. Another extension is regarding the underlaying structure, one can implement the model on other random networks such as Erdos-Renyi or Barabasi-Albert.


The model was implemented in NetLogo to support the following publication
Katarzyna Sznajd-Weron, Arkadiusz Jedrzejewski, Barbara Kaminska (2023), "Towards understanding of the social hysteresis---insights from agent-based modeling", submitted to Perspectives on Psychological Science. However, originally the model was introduced in [3].

If you mention the original model, we ask you to cite [3]. If you mention this implementation of the model in a publication, we ask that you include the citations below:

Katarzyna Sznajd-Weron, Arkadiusz Jedrzejewski, Barbara Kaminska (2023), "Towards understanding of the social hysteresis---insights from agent-based modeling", submitted to Perspectives on Psychological Science


This model was created as part of the project funded by the National Science Center (NCN, Poland) through grant no. 2019/35/B/HS6/02530


[1] Asch, S. E. (1955). Opinions and social pressure. Scientific American, 193(5), 31–35.
[2] C. Castellano, M.A. Muñoz, R. Pastor-Satorras, Nonlinear q -voter model. Physical review. E, 10 2009.
[3] P. Nyczka, K. Sznajd-Weron, J. Cisło, Phase transitions in the q-voter model with two types of stochastic driving. Phys. Rev. E, 07 2012

<!-- 2023 -->

(back to the NetLogo User Community Models)