[2312.01607] Monte Carlo Experiments of Network Effects in Randomized Controlled Trials
Marton Trencseni - Tue 09 April 2024 - monte-carlo-experiments-of-network-effects-in-randomized-controlled-trials
Monte Carlo Experiments of Network Effects in Randomized Controlled Trials
Abstract
I run Monte Carlo simulations of content production over random Watts-Strogatz graphs to show various effects relevant to modeling and understanding Randomized Controlled Trials on social networks: the network effect, spillover effect, experiment dampening effect, intrinsic dampening effect, clustering effect, degree distribution effect and the experiment size effect. I will also define some simple metrics to measure their strength. When running experiments these potentially unexpected effects must be understood and controlled for in some manner, such as modeling the underlying graph structure to establish a baseline.
1 Introduction
In academic as well as industry domains Randomized Controlled Trials (RCTs) are the gold standard tool for causal inference. Examples are clinical trials of new drugs and treatments, or improving online services and other online products. One of the core assumptions of traditional RCTs is the Independence Assumption (IA), that the units of experimentation are independent of each other. In plain words, the assumption is that units don’t communicate with each other, they do not affect other units’ outcomes based on their own experiences — whether they are in treatment or control. For many experiments ran on online services however — social networks such as Facebook or Twitter/X — the IA does not hold. The simplest toy example considered in this paper is a scenario of a treatment applied to a group of users that is intended to increase their content production. Increased content production of treatment users may boost content production of control users, since they will see their treatment friend’s additional posts in their feed, and thus be motivated or inclined to themselves post more. In this paper I consider this toy model, and examine various, potentially unexpected effects that affect (contaminate) an experiment run under such circumstances on a network, where the IA does not hold. To aid the discussion, I will also define some simple metrics to measure the strength of these effects.
2 Effects considered in this paper
To discuss and understand these network effects, the paper uses Monte Carlo simulations of RCTs of content production over random Watts-Strogatz graphs. The effects considered and discussed in this paper are:
-
1.
Network effect: each node’s neighbours’ content production boosts the node’s own content production.
-
2.
Degree distribution effect: the network effect boost is a function of the graph’s degree distribution.
-
3.
Spillover effect: in an experiment that boosts intrinsic content production in a subset of the nodes (the treatment group), this boost will spill over to the rest of the nodes.
-
4.
Experiment dampening effect: due to the spillover effect, we underestimate the lift in the treatment group as compared to control.
-
5.
Intrinsic dampening effect: the full lift of the treatment group is not realized in the network due to content production in the rest of the network being lower.
-
6.
Clustering effect: a more tightly clustered treatment group leads to higher lift compared to control.
-
7.
Experiment size effect: as we add more nodes to the treatment group, absolute content production increases in the treatment group (and the entire network) due to the network effects, but not relative to the control group.
3 Models of content production
The network is modeled as graph , where are nodes and are edges. For simplicity we assume edges are bi-directional, in other words the modeled relationship between nodes (such as friendship) is symmetric. Each node has an associated random variable , which describes the node’s propensity for content production. Furthermore, we assume the content production random variables follow the same distribution and are parameterized by a variable , such that . Without loss of generality, we will also assume that the random variables have an expectation value, and that . Specifically, we will parameterize the distributions such that . Note that in some of the Monte Carlo simulations, in cases when we are investigating the mean behaviour, we will replace the random variable with its mean — after verifying this is justified!
We construct a dynamic model of discrete time steps: let be the amount of content produced by node at time step . At all nodes have 0 content: . In subsequent time steps, we use the random variables for each node to model content production, in other words , where denotes drawing a value from the random variable. Note that we will omit indexes and superscripts at times to aid readability. We model the as having two components . The first parameter models the node’s intrinsic propensity to produce content, independent of the rest of the graph, and is the same for all nodes on a network. When we model experiments, it is the overall that will get boosted by for treatment nodes, like — this overall boost simplifies reasoning about the toy models. The second parameter models the propensity of the node to produce more content if its neighbours produce more content. We model as some function of the node’s neighbours content production in the previous time step: , where runs for all of ’s neighbours. Specifically, we will use , where is the set of nodes that are ’s neighbours. is an important global dampening parameter, whose presence is important to make the overall model stable in the steady-state (see next section).
The above model can be summed up as: at each time step , for each node, we add up content produced by its neighbours in the previous time step, multiply by , add , and draw with this parameter from the random variable to get content production at .
Throughout this paper we will use connected Watts–Strogatz random graphs. A Watts–Strogatz graph is described by 3 parameters . First, a regular ring lattice is constructed, a graph with nodes each connected to neighbors. Then, ”shortcuts” are created by replacing some edges as follows: for each original edge in the graph, with probability replace it with a new edge , where is randomly chosen. If the process yield a graph that is not connected, then try again until we get a connected graph. Note that the final randomization process does not change the mean degree in the graph, which remains at every step.
4 Mean behaviour, stability and the network effect
In the model constructed, there are two sources of randomness: (i) randomness introduced when the graph is constructed, and (ii) the random variables used in content production (if one is used). As we will see, to understand the network effects discussed in this paper (ii) is not important, and the random variable may be replaced by its mean.
First, to examine the mean behaviour of the model we run simulations on a Watts-Strogatz graph with . We look at three models of content production: (i) a uniform distribution , (ii) a Poisson distribution , and (iii) the mean constant case . Note that in all three cases, the mean is .
Figure 2 shows that content production stabilizes after about steps, and that that in all three cases mean content production across the network is the same, apart from random fluctuations coming from the random variables. Note that in case (i) and (iii) content production is modeled to be continuous, whereas in case of (ii) it’s discrete, since the Poisson is a discrete random variable. Figure 3 shows the histogram of content production across nodes in the last time step, for all three models considered.
In Figure 2, mean content production clearly stabilized. Next, let’s re-run the same simulations, but on a Watts-Strogatz graph with . The results are shown on Figure 4.
With these parameters content production diverges, it does not reach a steady-state as before. Consider the mean constant case to see why: assume that the model reaches a steady-state mean content production . Then, from the way the model is constructed it follows that (using ):
(1) |
where is the average number of neighbours per node, which for the Watts-Strogatz graph is always. Solving for we get:
(2) |
For the first model with this yield , which matches the numeric results. Clearly, this equation yields the stability condition:
(3) |
For the divergent case, the above inequality is not satisfied. It is interesting to see the case where the denominator in Equation (2) is exactly 0, which we can achieve by setting . In this case, content production does not explode, but increases linearly indefinitely.
This simple experiment of Figure 2 shows the network effect: we parameterized intrinsic content production with , which itself, without the boost from neighbours, would have yielded mean content production in this simple model. However, due to the network effect, which here is a function of and , the actual mean content production is significantly higher, by a factor of .
5 A note on regularizing models
Real networks can experience exponential growth for a while, but not indefinitely — some physical resource, such as people, attention or time runs out eventually. In this sense, the models above have unrealistic or un-physical domains because they can diverge. In principle, we can regularize the model in two places:
-
1.
regularize the network effect: assume that each node can only consume a finite amount of its neighbours’ content in a time step
-
2.
regularize content production: assume that each node can only produce a finite amount content
In both cases, the assumption is physical in a real network, because only finite time is available per time step to read or write content.
The simplest way to regularize is to cut off with the function, so that and . A smooth approach is to use a sigmoid function to achieve smoother cut-off: and .
Figure 6 shows the same model as Figure 5, but with (just) the network effect regularized. In this case, solving for we get:
(4) |
Due to the properties of , there is no closed form solution for in this case. In the rest of this paper, we will not use regularization, as it makes it harder to reason about the behaviour of the network — we will work with ”raw” models, but always use parameters that yield a stable network.
6 Degree distribution effect
In this section we will discuss a small, nuanced adjustment to the above formula for mean content production on a random graph that is due to the degree distribution of nodes. In a Watts-Strogatz graph with , all nodes have exactly neighbours; however, at , due to the random adjustment of edges, some nodes will end up with lower, and some with higher degree count than . Figure 6 shows the degree distribution of a Watts-Strogatz graph with at different values. It shows that with increasing , the distribution spreads out around the mean of .
When examining content production on these random graphs at different values, an interesting effect shows itself: mean content production increases in a concave way over the base value, which is only realized exactly in the case. Defining
(5) |
where is the actual content production measured in the network in steady-state and is the theoretically calculated value from Equation (2). Figure 8 shows the effect as a function of .
The explanation is as follows: the mean degree of nodes remains exactly in a Watts-Strogatz graph, despite (and during) the final randomization of edges, since the total number of nodes and edges always remains the same. However, as the histogram in Figure 7 shows, some nodes will end up with higher, and some with lower degree, and this is not entirely symmetric: on the lower side, the distribution is more bunched around the mean, whereas on the higher side, the degree distribution moves away further from the mean . As a result, some nodes will have a relatively high neighbour count, get a high network boost, and this is not cancelled out by the nodes having lower degree and experiencing lower network boost, since the distribution is not symmetric. This is illustrated in Figure 9, which shows the mean content production for the same graph as above, but as a function of node degree.
In the rest of the paper we will use the primed notation to refer to the ”bare” content production on the network, taking into account the above effect (so slightly higher than ). Bare here means no treatment is applied, all nodes are identical. Since there is no known formula for to me, it is calculated from a bare Monte Carlo network simulation in the rest of the paper.
7 Spillover effect
In this section we will start simulating Randomized Controlled Trials (RCTs) on networks. It’s important to point out that RCTs are traditionally run with the Independence Assumption (IA), that the units of experimentation are independent of each other. In the network models considered here, the IA does not hold — the resulting behaviour is the topic and raison d’etre of this paper itself.
Consider a model on a Watts-Strogatz graph with , with identical parameters as before, without regularization. Per Equation (2), such a model has an expected steady-state content production of . This base model is modified so that a random 2% treatment subset of nodes receives a boost to their overall content production. Figure 10 shows content production separately for treatment, neigbhours of treatment and the rest of nodes (these 3 are distinct sets covering the whole graph).
The following table shows the split of nodes and the average content production level of the various subsets in the network (control is the union of neighbours and rest):
group | cardinality | |
---|---|---|
treatment | 1.0258 | |
control | 1.0005 | |
neighbours | 1.0012 | |
rest | 0.9991 |
What this shows is that the treatment effect spills over into the control group. The spillover is stronger into direct neighbours of treatment, weaker for the rest of nodes. It’s also worth noting that treatment, control and neighbours subsets have higher content production than the simulated base value, which shows that even a small treatment group can ”contaminate” the entire network. However, rest (nodes that are not treatment and also not neighbours of treatment) has slightly lower () content production — how is this possible? The explanation is statistical: the nodes in rest are biased to have less neighbours, in this Monte Carlo simulation their mean degree is , and this results in this subset’s content production being slightly lower due to lower network effects (using the naive formula, . However, the overall conclusions are unaffected by this observation.
We can measure the strength of the spillover effect by defining:
(6) |
In other words, measures the degree of contamination (due to the treatment effect applied to the treatment group). In this scenario we measure .
Clearly, the spillover effect must be a function of and :
-
1.
as , because the treatment group becomes insignificant in the overall network
-
2.
as , because nodes have less neighbours and the model approaches a conventional RCT where the Independence Assumption holds
To illustrate the dependence on and , let’s look at the same experiment as above, but with and a 1% treatment group of nodes. In this scenario, where , the mean steady-state of the network is:
group | cardinality | |
---|---|---|
treatment | 1.0450 | |
control | 1.0000 | |
neighbours | 1.0014 | |
rest | 0.9999 |
The spillover effect works out to be , about 10x weaker than in the previous example.
8 Experiment dampening effect
In an RCT, we measure the treatment versus control group lift, and attribute it to be the effect of the applied treatment, with the caveat that one must be careful to separate out signal from noise using statistical hypothesis testing or bayesian inference. In the terminology of this paper, the treatment effect is defined as:
(7) |
In the previous two experiments, we measure and , respectively. Both are lower than the actual treatment effect we applied synthetically. This is the experiment dampening effect, a result of the spillover effect: because the treatment effect spills over into control and boosts control as well, we measure a lower treatment effect. We can define the experiment dampening effect as:
(8) |
In the cases above, we get and , respectively.
9 Intrinsic dampening effect
The reason experiments measure treatment against control in traditional RCTs is to factor out seasonal effects. If the experimenter were to compare the treatment group’s before-treatment and during-treatment (or after-treatment) metrics, she would not know whether the measured effect is due to the applied treatment, or something else that changed during the experiment. However, in our models, there is no seasonality, so we can examine . Let’s define the intrinsic dampening effect:
(9) |
This measures the dampening in the effect itself due to the connected, non-independent nature of the network. Naively, we may expect that this ratio should be just the applied treatment effect. However, as we will see, this is not the case. Specifically, for the first experiment considered previously, , for the second it is (note these are not the same values as for ). The full lift is not realized in the treatment group due to content production in the rest of the network being lower, hence, the feedback the treatment nodes receive in their term is lower. If the entire network were to receive the boost, in other words if , then the measured would hold, as is evident from Equation (2).
Note that the experiment dampening effect and the intrinsic dampening effect are related, but not the same thing:
-
1.
experiment dampening effect: we underestimate the lift in a treatment versus control measurement due to the treatment effect leaking to the control group in the network at treatment time
-
2.
intrinsic dampening effect: the full lift of the treatment group is not realized in the network due to content production being lower in the rest of the network (the control group) at treatment time; note that the control group does receive some of the treatment lift, so it’s content production also increases, but not to the level of the treatment group
10 Clustering effect
The clustering effect is a third effect closely related to the previous two: if the treatment nodes are more densely clustered than than the overall graph (or the control group), than the treatment nodes will achieve higher content production, both compared to the control group’s and the base rate .
In a randomized test, on average the treatment and control’s clustering should be the same, but variations may produce higher clustering in treatment; stratification controls for this in conventional RCTs. Or, an experiment may have selection bias and thus result is a more clustered treatment group.
To illustrate the effect, let’s look at a Monte Carlo run where the treatment nodes are not randomly selected, but significantly more clustered on purpose. To accomplish tighter clustering in a Watts-Strogatz graph is straightforward: instead of randomly selecting nodes, pick a contiguous set of nodes from the original ring (before randomization). At the relatively low edge randomization values that we’re using, this will result in a highly clustered subset.
We run an experiment with identical parameters as in Figure 10, except with a much more clustered treatment group: a Watts-Strogatz graph with , and , with a 2% treatment group of nodes receiving a boost to their content production.
However, previously, with a random treatment group the treatment nodes had non-treatment neighbours and 37.2% of treatment node’s neighbours were also in treatment, now the treatment nodes only have non-treatment neighbours and 90.6% of treatment node’s neighbours are also in treatment. This highly clustered model yields:
group | cardinality | |
---|---|---|
treatment | 1.0457 | |
control | 1.0001 | |
neighbours | 1.0052 | |
rest | 0.9995 |
The highly clustered case achieves , so there is barely any dampening, the treatment lift is 91% of the actual lift. The explanation is that 90% of the treatment group nodes’ neighbours are also in treatment, so they get ”their own boost back”, and there is relatively little dampening. It is also worth noting that , 5x lower than with a truly random treatment group. The explanation is that there are less edges running between treatment and control, so less ways for the spillover to happen.
11 Experiment size effect
The last effect we consider is the experiment size effect. The experiment size effect is closely related to the spillover effect, and is simply the observation that with a larger treatment group, there is stronger spillover, which yields stronger feedback, which results in higher content production in the treatment group. Figure 14 shows the variation of with for a Watts-Strogatz graph with and .
However, as pointed out earlier, in an RCT, the experimenter compares treatment content production to control’s (and not base). Figure 15 shows (the ratio of the treatment effect to the actual effect) for the same experiment. Remarkably, the dampening is essentially constant with , which means that even with increasing , the experimenter would measure the same treatment effect, because due to spillover, control’s content production also goes up.
Both plots split as a function of , the mean degree: the lower , the closer we are to the Independence Assumption, the more the measured treatment effect approaches . Separate experiments (not discussed here) show no dependence on .
12 Conclusion
In traditional RCTs where the Independence Assumption holds, the experimenters’ main focus is on study design and controlling for statistical fluctuations between the various experiment groups using techniques such as A/A tests, sample size mismatch tests, p-values, Bayesian testing, and so on. This paper showed that when running experiments on social networks or other graphs, where the IA does not hold, various other effects, all a result of the network effect, must be considered and controlled for. As the last section showed, even with high treatment group sizes, due to the treatment effect spilling over to the control group, the experimenter will never measure the true treatment effect when comparing treatment to control. This suggests that in networked conditions measuring or estimating the underlying graph structure and network effects, and then running simulations (similar to the ones in this paper) may be a good method to establish a baseline to compare treatment group behaviour with.
13 Code
The paper’s accompanying code, including all figures in the paper, is available as a Python notebook on Github. The random seed has been set to a fixed value in the code, so all numerical results are reproducible by re-running the notebook. Use the below link to access the notebook: https://github.com/mtrencseni/monte-carlo-network-effects-rct-2023
References
- Kohavi (2020) Kohavi, Tang, and Xu (2020). Trustworthy Online Controlled Experiments: A Practical Guide to A/B Testing. Cambridge University Press.
- Watts, Strogatz (1998) Watts, Strogatz (1998). Collective dynamics of ’small-world’ networks. Nature. 393 (6684): 440–442.
- Barabási (2002) Albert, Barabási (2002). Statistical mechanics of complex networks. Reviews of Modern Physics. 74 (1): 47–97. arXiv:cond-mat/0106096.