# local dynamical probabilities without graph knowledge Classic List Threaded 3 messages Open this post in threaded view
|

## local dynamical probabilities without graph knowledge

 Hi all, I've been trying to learn more about the Bayesian inference techniques introduced in https://journals.aps.org/prl/pdf/10.1103/PhysRevLett.123.128301 and have been having much joy trying the graph-tool software - it is a fantastic tool. I have been having difficulty understanding how one would estimate both the posterior distribution of a graph and the corresponding transmission probabilities in the SI dynamics example as suggested in the Twitter example of the aforementioned paper. For example taking the example from the cookbook (which is very clear) regarding these ideas but now assigning a edge property for the transmission probabilities (although leaving them homogeneous across all edges) ##################################### ### Look at using an edge based beta value # We will first simulate the dynamics with a given network g = gt.collection.data["dolphins"] tau = g.new_ep("double", .7)   # transmission probabilities ### simulate the dynamics ss = [] for i in range(100):     si_state = gt.SIState(g, beta=tau)     s = [si_state.get_state().copy()]     for j in range(10):         si_state.iterate_sync()         s.append(si_state.get_state().copy())     # Each time series should be represented as a single vector-valued     # vertex property map with the states for each node at each time.     s = gt.group_vector_property(s)     ss.append(s) #################################### and now considering the inference part my confusion is arising from how to assign a prior transmission value as a edge property when we are initializing the graph as empty. So below I am just changing the function collect_marginals as I want the local transmission probs (accessed through get_x() ) rather than the global beta as before and also not using a global beta in the block state. I assume here that if we were only interested in the transmisison probs i.e., not the graph posterior, then we'd assign an edge property to the graph but if we assume that we also don't know the edges I don't see how to assign the prior distribution. (I don't think beta = .7 is setting the prior to 0.7 beforehand but I may be mistaken here?) #################################### # Prepare the initial state of the reconstruction as an empty graph u = g.copy() u.clear_edges() ss = [u.own_property(s) for s in ss]   # time series properties need to be 'owned' by graph u def collect_marginals(s):    global gm, bs    gm = s.collect_marginal(gm)    bs.append(s.bstate.b.a.copy())    betas.append(s.get_x().copy()) # Create reconstruction state # but don't use a global beta and also don't state the no. of edges # note the prior beta is the same as the true one? rstate = gt.EpidemicsBlockState(u, s=ss, beta=.7, r=1e-6,                                 nested=False) # Now we collect the marginals for exactly 100,000 sweeps, at # intervals of 10 sweeps: gm = None bs = [] betas = [] gt.mcmc_equilibrate(rstate, force_niter=10000, mcmc_args=dict(niter=10, xstep=0),                     callback=collect_marginals) ################################## but when I access the arrays within betas after they all just consist of 0 values (through betas[i].get_array()) which makes me think I am not doing this process correctly (the graph similarities with the posterior and actual are also negligible~0.05). Any help with this problem (I may be doing something very incorrect in the process) and how to correctly implement an edge prior without knowledge of the graph would be greatly appreciated as I would like to delve further into these techniques. -- Sent from: https://nabble.skewed.de/_______________________________________________ graph-tool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graph-tool
 Administrator Am 08.10.20 um 17:16 schrieb j_nets: > but when I access the arrays within betas after they all just consist of 0 > values (through betas[i].get_array()) which makes me think I am not doing > this process correctly (the graph similarities with the posterior and actual > are also negligible~0.05). You should pass something different than xstep=0 if you want the transmission rates to actually change during MCMC. Take a look at the documentation of:   EpidemicsBlockState.mcmc_sweep() > Any help with this problem (I may be doing something very incorrect in the > process) and how to correctly implement an edge prior without knowledge of > the graph would be greatly appreciated as I would like to delve further into > these techniques. You cannot really change the prior of the edge transmission probabilities, since that is hard-coded for the uniform prior in this particular code. Best, Tiago -- Tiago de Paula Peixoto <[hidden email]> _______________________________________________ graph-tool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graph-tool signature.asc (849 bytes) Download Attachment -- Tiago de Paula Peixoto