mossspider.dgm.generate_truth

generate_truth(graph, p)

Simulates the true conditional mean outcome for a given network, distribution of W, and policy.

The true mean under the policy is simulated as

\[A = Bernoulli(p) \ Y = Bernoulli(expit(-2.5 + 1.5*W + 0.5*A + 1.5*map(A) + 1.5*map(W)))\]
Returns

Return type

float

Examples

Loading the necessary functions

>>> from mossspider.dgm import uniform_network, generate_truth

Generating the uniform network

>>> G = uniform_network(n=500, degree=[0, 2])

Calculating truth for a policy via a large number of replicates

>>> true_p = []
>>> for i in range(1000):
>>>     y_mean = generate_truth(graph=G, p=0.5)
>>>     true_p.append(y_mean)
>>> np.mean(true_p)  # 'true' value for the stochastic policy

To reduce random error, a large number of replicates should be used