Test_dat = dataObj {
    SOURCE {
        srcfile : {file = "TestData.csv", inputFormat is nonmemFormat}
    }

    DECLARED_VARIABLES {
        INPUT_CENTRAL :: dosingTarget
        Y :: observation
    }

    DATA_INPUT_VARIABLES {
        ID : {use is id}
        AMT : {use is amt, variable = INPUT_CENTRAL}
        TIME : {use is idv}
        DV : {use is dv, variable = Y}
        MDV : {use is mdv}
    }
}

Test_prior = priorObj {
    PRIOR_VARIABLE_DEFINITION {
        lMU_POP_K = ln(MU_POP_K)
        lMU_POP_V = ln(MU_POP_V)
        lPOP_K ~ Normal(mean=lMU_POP_K, var=VAR_POP_K)
        lPOP_V ~ Normal(mean=lMU_POP_V, var=VAR_POP_V)
        POP_K = exp(lPOP_K)
        POP_V = exp(lPOP_V)
        TAU_K ~ Gamma2(shape=a_OMEGA_K, rate=b_OMEGA_K)
        OMEGA_K = 1/TAU_K
        TAU_V ~ Gamma2(shape=a_OMEGA_V, rate=b_OMEGA_V)
        OMEGA_V = 1/TAU_V
        TAU ~ Gamma2(shape=a_POP_T, rate=b_POP_T)
        SD_ADD = 1/sqrt(TAU)
    }

    PRIOR_PARAMETERS {
        MU_POP_K = 0.1
        MU_POP_V = 8
        VAR_POP_K = 0.03
        VAR_POP_V = 0.03
        a_OMEGA_K = 1
        b_OMEGA_K = 0.01
        a_OMEGA_V = 1
        b_OMEGA_V = 0.01
        a_POP_T = 1
        b_POP_T = 0.01
    }
}

Test_mdl = mdlObj {
    OBSERVATION {
        Y : {additive = SD_ADD, eps = eps, prediction = CONC, type is additiveError}
    }

    VARIABILITY_LEVELS {
        ID : {level = 2, type is parameter}
        DV : {level = 1, type is observation}
    }

    VARIABILITY_PARAMETERS {
        OMEGA_K
        OMEGA_V
        SD_ADD
    }

    IDV {
        T
    }

    STRUCTURAL_PARAMETERS {
        POP_K
        POP_V
    }

    RANDOM_VARIABLE_DEFINITION(level=DV) {
        eps ~ Normal(mean=0, var=1)
    }

    RANDOM_VARIABLE_DEFINITION(level=ID) {
        eta_K ~ Normal(mean=0, var=OMEGA_K)
        eta_V ~ Normal(mean=0, var=OMEGA_V)
    }

    MODEL_PREDICTION {
    COMPARTMENT {
        INPUT_CENTRAL : {to = CENTRAL, type is direct}
        CENTRAL : {type is compartment}
         :: {from = CENTRAL, k = K, type is elimination, v = V}
    }

        CONC = CENTRAL/V
    }

    INDIVIDUAL_VARIABLES {
        K : {pop = POP_K, ranEff = eta_K, trans is ln, type is linear}
        V : {pop = POP_V, ranEff = eta_V, trans is ln, type is linear}
    }
}

BUGS_task = taskObj {
    ESTIMATE {
        set algo is mcmc
    TARGET_SETTINGS(target="BUGS") {
        set burnin = 1000
        set nchains = 1
        set niter = 5000
        set parameters = "POP_V,POP_K,OMEGA_V,OMEGA_K,SD_ADD"
        set winbugsgui = "true"
    }

    }
}

outputMog = mogObj {
    OBJECTS {
        Test_dat : {type is dataObj}
        Test_prior : {type is priorObj}
        Test_mdl : {type is mdlObj}
        BUGS_task : {type is taskObj}
    }
}
