示例#1
0
def lnprob(x, C0, P, D, t_steps, pops):
    xmin = zeros((len(x)))  # set boundaries of prior (non-zero prior prob for parameters)
    iswithinbounds = x > xmin
    if iswithinbounds.all():
        P['mortality']['0-1']['non-stunted'] = x[0]
        P['mortality']['0-1']['stunted'] = x[1]
        P['mortality']['1-6']['non-stunted'] = x[2]
        P['mortality']['1-6']['stunted'] = x[3]
        P['mortality']['6-12']['non-stunted'] = x[4] 
        P['mortality']['6-12']['stunted'] = x[5]
        P['mortality']['12-24']['non-stunted']= x[6] 
        P['mortality']['12-24']['stunted'] = x[7]
        P['mortality']['24-72']['non-stunted'] = x[8]
        P['mortality']['24-72']['stunted'] = x[9]
        
        return lnlike(C0, P, D, t_steps, pops)

    else:
        return -inf
示例#2
0
def lnprob(x, C0, P, D, t_steps, pops):
    xmin = zeros(
        (len(x)
         ))  # set boundaries of prior (non-zero prior prob for parameters)
    iswithinbounds = x > xmin
    if iswithinbounds.all():
        P['mortality']['0-1']['non-stunted'] = x[0]
        P['mortality']['0-1']['stunted'] = x[1]
        P['mortality']['1-6']['non-stunted'] = x[2]
        P['mortality']['1-6']['stunted'] = x[3]
        P['mortality']['6-12']['non-stunted'] = x[4]
        P['mortality']['6-12']['stunted'] = x[5]
        P['mortality']['12-24']['non-stunted'] = x[6]
        P['mortality']['12-24']['stunted'] = x[7]
        P['mortality']['24-72']['non-stunted'] = x[8]
        P['mortality']['24-72']['stunted'] = x[9]

        return lnlike(C0, P, D, t_steps, pops)

    else:
        return -inf
示例#3
0
def gridPlot2D(numpts, data_mc, data_dirt, a0s):

    # make empty grid
    a1svec = np.linspace(-8, 5, numpts)
    a2svec = np.linspace(-50, 50, numpts)

    a1s, a2s = np.meshgrid(a1svec, a2svec)
    lnlikes = np.zeros((len(a1s), len(a2s)))

    # make lnlikelihood matrix
    for i in tqdm(range(len(a1s))):
        for j in range(len(a2s)):

            theta = a0s, a1s[i][j], a2s[i][j]
            lnlikes[i][j] = lk.lnlike(theta, np.zeros(6), data_mc, data_dirt)
    '''
    # convert to delta s and MA s
    a3s = -20.*a0s - 10.*a1s - 4.*a2s
    a4s = 45*a0s + 20.*a1s + 6.*a2s
    a5s = -36.*a0s - 15.*a1s - 4.*a2s
    a6s = 10.*a0s + 4.*a1s + a2s

    t_cut = 9.*0.13957**2
    t0  = -0.28
    z0  = (np.sqrt(t_cut) - np.sqrt(t_cut-t0))/(np.sqrt(t_cut) + np.sqrt(t_cut - t0))

    GaS = a0s + a1s*z0 + a2s*z0**2 + a3s*z0**3 + a4s*z0**4 + a5s*z0**5 + a6s*z0**6
    MA  = np.sqrt(np.abs(2.*GaS/(a1s + 2.*a2s*z0 + 3.*a3s*z0**2 + 4.*a4s*z0**3 + 5.*a5s*z0**4 + 6.*a6s*z0**5)))
    '''

    plt.figure(figsize=(5, 3.5))
    plt.pcolor(a2s, a1s, np.exp(lnlikes), cmap=cmocean.cm.tempo)
    plt.xlabel(r'$a_2^s$', fontsize=16)
    plt.ylabel(r'$a_1^s$', fontsize=16)
    plt.tick_params(axis='both', which='major', labelsize=14)
    #plt.xlim(MA.min(),MA.max());
    #plt.ylim(GaS.min(),GaS.max());
    plt.colorbar()
示例#4
0
from model import steps
from likelihood import lnlike, model_outcomes
from inputs import get_data, get_params, get_initial_conditions
from mcmc import mcmc

pops = ['fertile_women', '0-1', '1-6', '6-12', '12-24', '24-72']
D = get_data()
P = get_params()
C0 = get_initial_conditions()

t_steps = 1000  # model run time (months)

# Run the model
y = steps(P, C0, t_steps)

LL = lnlike(C0, P, D, t_steps, pops)

# Parameters to calibrate
meta_prefit = dict()
meta_prefit['mortality, 0-1, non-stunted'] = P['mortality']['0-1'][
    'non-stunted']
meta_prefit['mortality, 0-1, stunted'] = P['mortality']['0-1']['stunted']
meta_prefit['mortality, 1-6, non-stunted'] = P['mortality']['1-6'][
    'non-stunted']
meta_prefit['mortality, 1-6, stunted'] = P['mortality']['1-6']['stunted']
meta_prefit['mortality, 6-12, non-stunted'] = P['mortality']['6-12'][
    'non-stunted']
meta_prefit['mortality, 6-12, stunted'] = P['mortality']['6-12']['stunted']
meta_prefit['mortality, 12-24, non-stunted'] = P['mortality']['12-24'][
    'non-stunted']
meta_prefit['mortality, 12-24, stunted'] = P['mortality']['12-24']['stunted']
示例#5
0
from model import steps
from likelihood import lnlike, model_outcomes
from inputs import get_data, get_params, get_initial_conditions
from mcmc import mcmc

pops = ['fertile_women', '0-1', '1-6', '6-12', '12-24', '24-72']
D = get_data()
P = get_params()
C0 = get_initial_conditions()

t_steps = 1000  # model run time (months)

# Run the model
y = steps(P, C0, t_steps)

LL = lnlike(C0, P, D, t_steps, pops)


# Parameters to calibrate
meta_prefit = dict()
meta_prefit['mortality, 0-1, non-stunted'] = P['mortality']['0-1']['non-stunted']
meta_prefit['mortality, 0-1, stunted'] = P['mortality']['0-1']['stunted']
meta_prefit['mortality, 1-6, non-stunted'] = P['mortality']['1-6']['non-stunted']
meta_prefit['mortality, 1-6, stunted'] = P['mortality']['1-6']['stunted']
meta_prefit['mortality, 6-12, non-stunted'] = P['mortality']['6-12']['non-stunted']
meta_prefit['mortality, 6-12, stunted'] = P['mortality']['6-12']['stunted']
meta_prefit['mortality, 12-24, non-stunted'] = P['mortality']['12-24']['non-stunted']
meta_prefit['mortality, 12-24, stunted'] = P['mortality']['12-24']['stunted']
meta_prefit['mortality, 24-72, non-stunted'] = P['mortality']['24-72']['non-stunted']
meta_prefit['mortality, 24-72, stunted'] = P['mortality']['24-72']['stunted']