Data4DM / BayesSD

Data for Decision, Affordable Analytics for All
8 stars 0 forks source link

Compare vensim and stanify #58

Closed hyunjimoon closed 5 months ago

hyunjimoon commented 1 year ago

S = 30, M = 1000 (vensim and stan would be different but non-autocorrelated, converged sample), N = 20 image

without process noise, with measurement noise

  1. Compare the average: prior_pred_obs: https://github.com/Data4DM/stanify/blob/main/stanify_demo.py#L47

Use alpha, beta, gamma, delta prior dist defined in draws2data stan file.

We assume stan's rng and vensim's rng is similar. In stan, prey_obs ~ normal_rng(prey, m_noise_scale)

array([ 0.24878059,  0.29612573,  0.55957889,  0.06677449, -2.04914881,
       -0.08381008, -0.82436614,  0.5243477 , -0.60570814, -0.37597002,
       -0.92898971,  0.0248358 ,  0.60356123, -0.75828866,  0.12360369,
        0.18310545, -0.37519184, -0.77519677,  0.07079331,  0.17829731])

Compare prey_obs, predator_obs image

estimate for without process noise

image

with process noise, with measurement noise

Consistency of realized random variable should be matched. Lookup function (CDF) is the right way to go. make sure np.random.normal(0,1, size=n_t) is used

array([ 0.24878059,  0.29612573,  0.55957889,  0.06677449, -2.04914881,
       -0.08381008, -0.82436614,  0.5243477 , -0.60570814, -0.37597002,
       -0.92898971,  0.0248358 ,  0.60356123, -0.75828866,  0.12360369,
        0.18310545, -0.37519184, -0.77519677,  0.07079331,  0.17829731])

image

hyunjimoon commented 1 year ago

image @tomfid updated result (uploaded in stanify repo); surprising process noise makes estimation stable.