예제 #1
0
def write_parametric(f, Bpar, runtime):
    outs  = "%g %g %g " % (Bpar.estimate[0],Bpar.getCI(1,(.025,)),Bpar.getCI(1,(.975))) # m.par.e m.par.l m.par.h
    outs += "%g %g %g " % (Bpar.estimate[1],ptile(Bpar.mcestimates[:,1],2.5),ptile(Bpar.mcestimates[:,1],97.5)) # w.par.e w.par.l w.par.h
    outs += "%g %g %g " % (Bpar.deviance, ptile(Bpar.mcdeviance,95), psigcorrect.estimate_nu (Bpar)[0]) # d.par d.par.crit nu.par
    outs += "%g %g %g " % (Bpar.Rpd,ptile(Bpar.mcRpd,2.5),ptile(Bpar.mcRpd,97.5)) # rpd.par rpd.par.l rpd.par.h
    outs += "%g %g %g " % (Bpar.Rkd,ptile(Bpar.mcRkd,2.5),ptile(Bpar.mcRkd,97.5)) # rkd.par rkd.par.l rkd.par.h
    outs += ("%g "*options.nblocks) % tuple(Bpar.infl)
    outs += "%g " % runtime
    f.write(outs)
예제 #2
0
def write_parametric(f, Bpar, runtime):
    outs = "%g %g %g " % (Bpar.estimate[0], Bpar.getCI(
        1, (.025, )), Bpar.getCI(1, (.975)))  # m.par.e m.par.l m.par.h
    outs += "%g %g %g " % (Bpar.estimate[1], ptile(
        Bpar.mcestimates[:, 1], 2.5), ptile(Bpar.mcestimates[:, 1], 97.5)
                           )  # w.par.e w.par.l w.par.h
    outs += "%g %g %g " % (Bpar.deviance, ptile(
        Bpar.mcdeviance, 95), psigcorrect.estimate_nu(Bpar)[0]
                           )  # d.par d.par.crit nu.par
    outs += "%g %g %g " % (Bpar.Rpd, ptile(Bpar.mcRpd,
                                           2.5), ptile(Bpar.mcRpd, 97.5)
                           )  # rpd.par rpd.par.l rpd.par.h
    outs += "%g %g %g " % (Bpar.Rkd, ptile(Bpar.mcRkd,
                                           2.5), ptile(Bpar.mcRkd, 97.5)
                           )  # rkd.par rkd.par.l rkd.par.h
    outs += ("%g " * options.nblocks) % tuple(Bpar.infl)
    outs += "%g " % runtime
    f.write(outs)
예제 #3
0
def write_bayes(f, mcmc, mcmc_conv, runtime):
    outs  = "%g %g %g %g %g " % (
            mcmc.estimate[0],        # m.bay.m
            mcmc.mapestimate[0],     # m.bay.map
            mcmc.posterior_median[0],# m.bay.median
            mcmc.getCI(1,(.025,)),   # m.bay.l
            mcmc.getCI(1,(.975)))    # m.bay.h

    outs += "%g %g %g %g %g " % (
            mcmc.estimate[1],                  # w.bay.m
            mcmc.mapestimate[1],               # w.bay.map
            mcmc.posterior_median[1],          # w.bay.median
            ptile(mcmc.mcestimates[:,1],2.5),  # w.bay.l
            ptile(mcmc.mcestimates[:,1],97.5)) # w.bay.h
    outs += "%g %g %g " % (mcmc.deviance,mcmc.bayesian_p('deviance'), psigcorrect.estimate_nu (mcmc)[0]) # d.bay d.bay.p
    outs += "%g %g " % (mcmc.Rpd,mcmc.bayesian_p('Rpd')) # d.rpd d.rpd.p
    outs += "%g %g " % (mcmc.Rkd,mcmc.bayesian_p('Rkd')) # d.rkd d.rkd.p
    outs += "%d %g %g %g " % (mcmc_conv,mcmc.Rhat(0),mcmc.Rhat(1),mcmc.Rhat(2))
    outs += ("%g "*options.nblocks) % tuple(mcmc.infl)
    outs += "%g " % runtime
    f.write(outs)
예제 #4
0
def write_bayes(f, mcmc, mcmc_conv, runtime):
    outs = "%g %g %g %g %g " % (
        mcmc.estimate[0],  # m.bay.m
        mcmc.mapestimate[0],  # m.bay.map
        mcmc.posterior_median[0],  # m.bay.median
        mcmc.getCI(1, (.025, )),  # m.bay.l
        mcmc.getCI(1, (.975)))  # m.bay.h

    outs += "%g %g %g %g %g " % (
        mcmc.estimate[1],  # w.bay.m
        mcmc.mapestimate[1],  # w.bay.map
        mcmc.posterior_median[1],  # w.bay.median
        ptile(mcmc.mcestimates[:, 1], 2.5),  # w.bay.l
        ptile(mcmc.mcestimates[:, 1], 97.5))  # w.bay.h
    outs += "%g %g %g " % (mcmc.deviance, mcmc.bayesian_p('deviance'),
                           psigcorrect.estimate_nu(mcmc)[0])  # d.bay d.bay.p
    outs += "%g %g " % (mcmc.Rpd, mcmc.bayesian_p('Rpd'))  # d.rpd d.rpd.p
    outs += "%g %g " % (mcmc.Rkd, mcmc.bayesian_p('Rkd'))  # d.rkd d.rkd.p
    outs += "%d %g %g %g " % (mcmc_conv, mcmc.Rhat(0), mcmc.Rhat(1),
                              mcmc.Rhat(2))
    outs += ("%g " * options.nblocks) % tuple(mcmc.infl)
    outs += "%g " % runtime
    f.write(outs)
예제 #5
0
        print count_bay, mcmc.getCI(1,(.025,.975))
        toc = time.time()
        write_bayes(outfile, mcmc, mcmc_conv, toc-tic)
        print "Done Bayes"

    write_data(outfile, data)
    outfile.write ("\n")
    outfile.flush()

# datareduce section is not up-to-date
# current state is that it doesn't seem to help much for improving the results
# in case you want to use this you must first make it work again
    if False:
        data = array ( data )
        dataml = data.copy ()
        nu = psigcorrect.estimate_nu (Bpar)[0]
        print "==============", nu, "==============="
        dataml[:,1] = ( data[:,1] * nu ).astype("i")
        dataml[:,2] = ( data[:,2] * nu ).astype("i")
        print dataml
        try:
            Bnpr = pypsignifit.BootstrapInference ( dataml, sample=options.nbootstrap, priors=constraints, parametric=False, **ana_kwargs )
        except:
            sys.stderr ( "An error ocurred in simulation %d during nonparametric bootstrap\n" % ( simulation,) )
        print "Done npar"
        try:
            Bpar = pypsignifit.BootstrapInference ( dataml, sample=options.nbootstrap, priors=constraints, parametric=True,  **ana_kwargs )
        except:
            sys.stderr ( "An error ocurred in simulation %d during parametric bootstrap\n" % ( simulation,) )
        print "Done par"
예제 #6
0
        print count_bay, mcmc.getCI(1, (.025, .975))
        toc = time.time()
        write_bayes(outfile, mcmc, mcmc_conv, toc - tic)
        print "Done Bayes"

    write_data(outfile, data)
    outfile.write("\n")
    outfile.flush()

    # datareduce section is not up-to-date
    # current state is that it doesn't seem to help much for improving the results
    # in case you want to use this you must first make it work again
    if False:
        data = array(data)
        dataml = data.copy()
        nu = psigcorrect.estimate_nu(Bpar)[0]
        print "==============", nu, "==============="
        dataml[:, 1] = (data[:, 1] * nu).astype("i")
        dataml[:, 2] = (data[:, 2] * nu).astype("i")
        print dataml
        try:
            Bnpr = pypsignifit.BootstrapInference(dataml,
                                                  sample=options.nbootstrap,
                                                  priors=constraints,
                                                  parametric=False,
                                                  **ana_kwargs)
        except:
            sys.stderr(
                "An error ocurred in simulation %d during nonparametric bootstrap\n"
                % (simulation, ))
        print "Done npar"