These functions play models of opinion dynamics upon networks, in which nodes change their opinions towards those of the nodes they listen to.
play_opinion() plays an opinion model upon a network,
and returns the network with a record of the opinions in its changes.
as_opinion() reads the record of an opinion from a network,
such as one that play_opinion() returns,
and returns a table of the opinion of each node at each step.
This table is of the class 'opinionModel',
with 'learn_model' as its second class for one release.
The opinions are numbers, such as the probability that a node
puts on some statement being true, or a position on a scale.
For opinions that are categories, see play_diffusion().
as_opinion(.data, opinions = "opinions")
play_opinion(
.data,
opinions,
rule = c("degroot", "hegselmann_krause", "deffuant"),
stubbornness = 0,
confidence = Inf,
weights = NULL,
steps,
tolerance = 5e-04
)A network.
For as_opinion(), a network with a record of opinions
in its changes, or an 'opinionModel'.
The opinions of the nodes at the start. One of:
a numeric or logical vector, with one value for each node,
which is recorded as the node attribute "opinions";
the name of a numeric node attribute, which is then also the name under which the changes are recorded;
a matrix of nodes by issues, with one column for each issue,
recorded under its column names, or "opinions_1", "opinions_2", and
so on.
Several names of node attributes are read as several issues.
For as_opinion(), the name of the node attribute whose record is read.
The rule by which the nodes update their opinions,
one of "degroot" (the default), "hegselmann_krause", or "deffuant".
See the section on rules below.
How much each node holds on to its first opinion, from 0 (the default, DeGroot's model) to 1 (it never moves). One value for all the nodes, a vector with one value for each node, or the name of a numeric node attribute.
How far apart two opinions can be for one node still to
listen to the other.
A node listens only to the nodes it is tied to whose opinions are
within confidence of its own, and ignores the rest.
For example, with opinions from 0 to 1 and confidence = 0.2,
a node with an opinion of 0.5 listens to its neighbours from 0.3 to 0.7.
A small value lets opinions settle into several separate clusters,
and a large value lets them meet in one.
The name comes from models of "bounded confidence",
in which a node trusts only opinions close enough to its own.
It is used only by "hegselmann_krause" and "deffuant".
By default Inf, so that every node listens to all the nodes
it is tied to.
How the influence of one node on another is weighed.
By default NULL, which uses the ties of the network,
with their weights where the network is weighted,
normalised so that the ties each node sends sum to 1.
Self-loops are kept as self-weights.
Otherwise the name of a numeric tie attribute to weigh the ties by,
or a matrix with one row and column for each node,
whose absolute values sum to 1 in each row, which is used as it is.
A negative value is a tie of repulsion.
The largest number of steps to play. By default the number of nodes in the network.
The smallest change in an opinion that counts. The run stops when no opinion changes by this much in a step, and smaller changes are not recorded.
as_opinion() returns an 'opinionModel' (a data frame),
with one row for each step from the start,
and one column for each node.
play_opinion() returns the network of the class it was given,
with the opinions at the start as node attributes,
and the later changes in its changes.
A matrix or an edgelist cannot hold these, so for one of them
a 'stocnet' is returned.
rule chooses how the nodes update their opinions at each step:
"degroot" (the default): all nodes at once take the average of the
opinions of the nodes they listen to, weighted by the influence matrix W
(DeGroot 1974).
This is deterministic.
On a connected network with no stubbornness, it reaches a consensus.
"hegselmann_krause": all nodes at once take the weighted average of
their own opinion and the opinions of only those nodes they listen to
whose opinions are within confidence of their own
(Hegselmann and Krause 2002).
As in that model, a node always counts its own opinion:
with its self-weight where the network has a self-tie,
or else with the weight of its average tie,
so that on an unweighted network every opinion it counts has the same weight.
This is deterministic, and opinions can settle into several clusters.
"deffuant": at each step, one node is drawn at random,
and it draws one of the nodes it listens to, in proportion to W.
If their opinions are within confidence of each other,
each moves halfway towards the other, where it listens to the other
(Deffuant et al. 2000).
This is stochastic, so set a seed to repeat a result.
Since only one pair can change at each step, this rule usually needs
many more steps than the others.
confidence is used only by the bounded-confidence rules,
"hegselmann_krause" and "deffuant".
Where opinions hold several issues,
the distance between two nodes' opinions is the Euclidean distance
across the issues.
A negative tie from i to j means that i moves away from the opinion of j,
towards the opposite opinion (Altafini 2013).
See to_influence() for how such ties are weighed.
Opposite opinions are opposite signs, so give the opinions on a scale
centred on 0, such as from -1 to 1.
Where the network is structurally balanced, with only negative ties
between two camps, the opinions split into two camps of the same size
and opposite signs.
Where it is not balanced, the opinions are pulled towards 0.
Only the "degroot" rule can yet use negative ties.
Two quantities decide how much a node holds on to its own opinion:
Its self-weight is how much it listens to itself,
compared with the nodes it listens to.
It is the diagonal of W, and in a network it is a self-loop:
a loop of weight 2 on a node with one tie of weight 1 to another node
gives that node a self-weight of 2/3 (see to_influence()).
A self-weight pulls a node towards its current opinion.
Its stubbornness is how much it keeps its first opinion,
compared with what the network says.
It is stubbornness, where 0 is DeGroot's model and
1 is a node that never moves from its first opinion.
The update is \(x(t+1) = (I - S) W x(t) + S x(0)\),
where \(S\) is the diagonal matrix of stubbornness.
This is the model of Friedkin and Johnsen (1990),
and stubbornness is 1 minus what they call susceptibility.
On a path A–B–C with the first opinions 0, 0.5, and 1:
| Setting | Final opinions | What it shows |
| No self-weight, stubbornness 0 (DeGroot) | 0.5, 0.5, 0.5 | Consensus. |
| Self-weight 1/2 at every node | 0.5, 0.5, 0.5 | Slower, but the same consensus. |
| Self-weight 2/3 at A only | 0.33, 0.33, 0.33 | A has more influence, but there is still a consensus. |
| Stubbornness 0.5 at every node | 0.25, 0.5, 0.75 | Disagreement lasts. |
| Stubbornness 1 at A | 0, 0, 0 | A pulls everyone to its first opinion. |
| Self-weight 1 at A | 0, 0, 0 | The same as stubbornness 1: A listens only to itself. |
So a node that listens only to itself is fully stubborn.
That is the only case where the two quantities give the same result.
With self-weights alone, disagreement lasts only where two or more nodes
are fully stubborn, or where the network is not connected.
With stubbornness, disagreement lasts also where every node is only
partly stubborn.
The models make these assumptions, which an analysis may need to state:
Time is in discrete steps.
For "degroot" and "hegselmann_krause", all nodes update at once,
from the opinions at the start of the step (synchronous updates).
For "deffuant", one pair meets at each step (asynchronous updates).
Ties carry influence along their direction.
A tie from i to j means that i listens to j.
Each row of W divides the absolute tie weights of a node by their sum,
so a node with more ties gives less weight to each (see to_influence()).
The layers of a multiplex network are first combined into one matrix,
as as_matrix() combines them.
A node does not listen to itself under "degroot" and "deffuant",
unless the network gives it a self-tie.
This is why a periodic network, such as a ring of an even length,
can swing for ever (see is_aperiodic()).
Under "hegselmann_krause", a node always counts its own opinion.
Stubbornness pulls towards the first opinion, not the current one, and it does not change during the run.
The network does not change during the run, and the opinions do not change the ties.
The run stops when no opinion moves by tolerance in a step,
so the last row is near, but not exactly at, the opinions at the end.
netrics::node_by_opinion() gives these exactly, where they exist.
play_opinion() returns the network it was given,
with the opinions at the start as a node attribute,
and each later change in the changes of the network.
A node gets a row for a step only where its opinion has moved by more
than tolerance since its last row, so the record stays small,
and as_opinion() rebuilds each step to within tolerance.
The run stops when no opinion moves by tolerance or more in a step,
or, for "deffuant", when no pair that listens to each other
can move any more, or after steps steps.
Where the attribute named by opinions already has a record,
the run continues from the last opinions and the last time of that record.
DeGroot, Morris H. 1974. "Reaching a consensus", Journal of the American Statistical Association, 69(345): 118–21. doi:10.1080/01621459.1974.10480137
Deffuant, Guillaume, David Neau, Frederic Amblard, and Gérard Weisbuch. 2000. "Mixing beliefs among interacting agents", Advances in Complex Systems, 3(1): 87-98. doi:10.1142/S0219525900000078
Friedkin, Noah E., and Eugene C. Johnsen. 1990. "Social influence and opinions", Journal of Mathematical Sociology, 15(3-4): 193-206. doi:10.1080/0022250X.1990.9990069
Golub, Benjamin, and Matthew O. Jackson 2010. "Naive learning in social networks and the wisdom of crowds", American Economic Journal, 2(1): 112-49. doi:10.1257/mic.2.1.112
Altafini, Claudio. 2013. "Consensus problems on networks with antagonistic interactions", IEEE Transactions on Automatic Control, 58(4): 935-946. doi:10.1109/TAC.2012.2224251
Hegselmann, Rainer, and Ulrich Krause. 2002. "Opinion dynamics and bounded confidence: Models, analysis and simulation", Journal of Artificial Societies and Social Simulation, 5(3).
Other makes:
as_diffusion(),
as_mobility(),
make_bibliography,
make_create,
make_ego,
make_emails,
make_explicit,
make_groups,
make_growth,
make_packages,
make_random,
make_read,
make_statements,
make_text,
make_write
Other models:
as_diffusion(),
as_mobility()
as_opinion(play_opinion(create_ring(6), opinions = 1:6/6))
#> # A tibble: 7 × 6
#> V1 V2 V3 V4 V5 V6
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.167 0.333 0.5 0.667 0.833 1
#> 2 0.667 0.333 0.5 0.667 0.833 0.5
#> 3 0.417 0.583 0.5 0.667 0.583 0.75
#> 4 0.667 0.458 0.625 0.542 0.708 0.5
#> 5 0.479 0.646 0.5 0.667 0.521 0.688
#> 6 0.667 0.490 0.656 0.510 0.677 0.5
#> 7 0.495 0.661 0.5 0.667 0.505 0.672
net <- play_opinion(ison_networkers,
opinions = rbinom(net_nodes(ison_networkers), 1, prob = 0.25))
as_opinion(net)
#> # A tibble: 8 × 32
#> `Lin Freeman` `Doug White` `Ev Rogers` `Richard Alba` `Phipps Arabie`
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0 0 0 1 1
#> 2 0.254 0.196 0 0.175 0.155
#> 3 0.193 0.206 0.195 0.233 0.220
#> 4 0.211 0.207 0.201 0.205 0.206
#> 5 0.206 0.208 0.206 0.207 0.209
#> 6 0.207 0.207 0.207 0.207 0.207
#> 7 0.207 0.207 0.207 0.207 0.207
#> 8 0.207 0.207 0.207 0.207 0.207
#> # ℹ 27 more variables: `Carol Barner-Barry` <dbl>, `Gary Coombs` <dbl>,
#> # `Russ Bernard` <dbl>, `John Boyd` <dbl>, `Ron Burt` <dbl>,
#> # `Pat Doreian` <dbl>, `Claude Fischer` <dbl>, `Brian Foster` <dbl>,
#> # `Mark Granovetter` <dbl>, `Maureen Hallinan` <dbl>, `Paul Holland` <dbl>,
#> # `Jack Hunter` <dbl>, `Davor Jedlicka` <dbl>, `Charles Kadushin` <dbl>,
#> # `Ed Laumann` <dbl>, `Sam Leinhardt` <dbl>, `Joel Levine` <dbl>,
#> # `Nan Lin` <dbl>, `Nick Mullins` <dbl>, `Don Ploch` <dbl>, …
# A stubborn node pulls the others towards its first opinion
path <- create_explicit(A-B-C)
as_opinion(play_opinion(path, opinions = c(0, 0.5, 1),
stubbornness = c(1, 0, 0), steps = 50))
#> # A tibble: 20 × 3
#> A B C
#> <dbl> <dbl> <dbl>
#> 1 0 0.5 1
#> 2 0 0.5 0.5
#> 3 0 0.25 0.5
#> 4 0 0.25 0.25
#> 5 0 0.125 0.25
#> 6 0 0.125 0.125
#> 7 0 0.0625 0.125
#> 8 0 0.0625 0.0625
#> 9 0 0.0312 0.0625
#> 10 0 0.0312 0.0312
#> 11 0 0.0156 0.0312
#> 12 0 0.0156 0.0156
#> 13 0 0.00781 0.0156
#> 14 0 0.00781 0.00781
#> 15 0 0.00391 0.00781
#> 16 0 0.00391 0.00391
#> 17 0 0.00195 0.00391
#> 18 0 0.00195 0.00195
#> 19 0 0.000977 0.00195
#> 20 0 0.000977 0.000977