example331_dat = dataObj {
   DECLARED_VARIABLES{ DOSE::dosingTarget Y::observation}
   DATA_INPUT_VARIABLES{
      ID:{use is id}
      TIME:{use is idv}
      AMT:{use is amt, variable=DOSE}
      DV:{use is dv, variable=Y}
   }# end DATA_INPUT_VARIABLES

   SOURCE{
   mysrcfile:{file="bo1.csv",
      inputFormat is nonmemFormat}
   }# end SOURCE
     
}

example3423_pri = priorObj{
   PRIOR_PARAMETERS{

	   bins_POP_K = [2.006510,2.045465,2.084421,2.123377,2.162333,2.201288,2.240244,2.279200,2.318156,2.357111 ] 
	   p_POP_K = [0.033333,0.100000,0.100000,0.200000,0.100000,0.066667,0.166667,0.100000,0.066667,0.066667 ]
	   data_POP_V = [5.050013,5.050013,5.050013,5.050013,5.064166,5.064166,5.064166,5.064166,5.078318,5.078318 ]

        # prior on "OMEGA"
		a_OMEGA_K = 0.1
		b_OMEGA_K = 0.1
		a_OMEGA_V = 0.1
		b_OMEGA_V = 0.1
        a_OMEGA_T = 0.3
		b_OMEGA_T = 0.3
		
		# prior on "SIGMA"
        a_POP_T = 0.1
		b_POP_T = 0.1
   
   } # end PRIOR_PARAMETERS

   PRIOR_VARIABLE_DEFINITION{
      # prior on "THETA"   
 
	  POP_K ~ NonParametric(bins=bins_POP_K, probability=p_POP_K)
      POP_V ~ Empirical(data=data_POP_V)

	  # prior on "OMEGA"	
      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_T ~ Gamma2(shape=a_OMEGA_T, rate=b_OMEGA_T)
      OMEGA_T = 1/TAU_T             

      # prior on "SIGMA"  
      POP_T ~ Gamma2(shape=a_POP_T, rate=b_POP_T)                
    } # end PRIOR_VARIABLE_DEFINITION
} # end of Prior Object

example331_mdl = mdlObj{
	IDV{ T }
	
	VARIABILITY_LEVELS{
		ID:{level=2, type is parameter}
		DV:{level=1, type is observation}
	}

# <<<< Relevant model parameters are selected from the PRIOR_VARIABLE_DEFINITION block  
# <<<< and listed in the STRUCTURAL_PARAMETERS and VARIABILITY_PARAMETERS blocks as usual >>>
   STRUCTURAL_PARAMETERS{
      POP_K
      POP_V
      POP_T
   }# end STRUCTURAL_PARAMETERS

   VARIABILITY_PARAMETERS{
      OMEGA_K
      OMEGA_V
      OMEGA_T
   }# end VARIABILITY_PARAMETERS


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

   INDIVIDUAL_VARIABLES{
      K : {type is linear, trans is ln, pop = POP_K, ranEff=eta_K}
      V : {type is linear, trans is ln, pop = POP_V, ranEff=eta_V}
      TAU : {type is linear, trans is ln, pop = POP_T, ranEff=eta_T}
      SD_ADD = sqrt(1/TAU)
   }# end INDIVIDUAL_VARIABLES

   MODEL_PREDICTION{   
      DOSE :: dosingVar
      C=DOSE/V*exp(-K*T)
   }# end MODEL_PREDICTION   
   
   RANDOM_VARIABLE_DEFINITION(level=DV){
   		eps ~ Normal( mean=0, var=1)
   	}
   
   OBSERVATION{
      Y : {type is additiveError, additive=SD_ADD, eps=eps, prediction= C}
   }# end OBSERVATION  

} # end of model object

example331_task = taskObj{   
    ESTIMATE { 
    	set algo is mcmc  
	} 
} # end task
	
example3423 = mogObj{
	OBJECTS{
		example331_dat : { type is dataObj }
		example331_mdl : { type is mdlObj }
		example3423_pri : { type is priorObj }
		example331_task : { type is taskObj }
	}
}


