def bad_alpha_sampler_simple_sim(n=[33, 21, 22, 22, 24, 11]): # generate data and model d = data.simple_hierarchical_data(n) m = models.simple_hierarchical_model(d['y']) # fit model with MCMC, but with badly initialized step method mcmc = mc.MCMC(m) mcmc.use_step_method(mc.AdaptiveMetropolis, [m['inv_sigma_sq'], m['mu'], m['inv_tau_sq']]) mcmc.use_step_method(mc.NoStepper, m['alpha']) mcmc.sample(60000, 10000, 10) return d, m
def good_simple_sim(n=[33, 21, 22, 22, 24, 11]): # generate data and model d = data.simple_hierarchical_data(n) m = models.simple_hierarchical_model(d['y']) # fit model with MCMC mcmc = mc.MCMC(m) mcmc.use_step_method(mc.AdaptiveMetropolis, [m['inv_sigma_sq'], m['mu'], m['inv_tau_sq']]) mcmc.use_step_method(mc.AdaptiveMetropolis, [m['alpha']]) mcmc.sample(60000, 10000, 10) return d, m
def bad_mu_prior_simple_sim(n=[33, 21, 22, 22, 24, 11]): # generate data and model, intentionally misspecifying prior on mu d = data.simple_hierarchical_data(n) m = models.simple_hierarchical_model(d['y']) m['mu'].parents['mu'] = -5. m['mu'].parents['tau'] = .001**-2 # fit model with MCMC mcmc = mc.MCMC(m) mcmc.use_step_method(mc.AdaptiveMetropolis, [m['inv_sigma_sq'], m['mu'], m['inv_tau_sq']]) mcmc.use_step_method(mc.AdaptiveMetropolis, [m['alpha']]) mcmc.sample(60000, 10000, 10) return d, m
def test_simple_model(self): p = [[1,2,3], [4,5,6,7]] vars = models.simple_hierarchical_model(p) assert 'y' in vars
def test_simple_model(self): p = [[1, 2, 3], [4, 5, 6, 7]] vars = models.simple_hierarchical_model(p) assert 'y' in vars