----------------------------------------------- lines 5-97 of file: example/user/const_value.py ----------------------------------------------- # {xrst_begin user_const_value.py} # {xrst_comment_ch #} # # Constrain Omega Using const_value # ################################# # # Node Table # ********** # For this example the :ref:`node_table-name` is # :: # # universe # | # world # / \ # child_1 child_2 # # Problem Parameters # ****************** # The following values are used to simulate the data and set the priors # for fitting the data: # {xrst_spell_off} # {xrst_code py} iota_true = { 'world':0.004, 'child_1':0.002, 'child_2':0.008 } omega_true = { 'world':0.01, 'child_1':0.005, 'child_2':0.002 } n_data = 51 # {xrst_code} # {xrst_spell_on} # # Child Random Effects # ******************** # The following code converts the child rates to child rate effects: # {xrst_spell_off} # {xrst_code py} import math for key in [ 'child_1', 'child_2' ] : iota_true[key] = math.log( iota_true[key] / iota_true['world'] ) omega_true[key] = math.log( omega_true[key] / omega_true['world'] ) # {xrst_code} # {xrst_spell_on} # # Omega Priors # ************ # The parent and child rates for omega are constrained to be their # true value using the :ref:`smooth_grid_table@const_value` # column in the smooth_grid table. # # nslist # ====== # Note that the different children have different priors for the # child random effects which requires using the # :ref:`child_nslist` option in the # rate table. # # Iota Priors # *********** # The iota priors are uniform. # # Parent # ====== # For the parent, the lower (upper) limit is the true value # divided by ten (multiplied by ten). # The mean, which is two times the true value, is used for the # :ref:`start_var_table-name` and :ref:`scale_var_table-name` ; # see :ref:`init_command-name` . # # Data # **** # All of the data for this example is direct measurements of the # :ref:`avg_integrand@Integrand, I_i(a,t)@susceptible` # population (as a fraction of the initial population). # # random_seed # *********** # Use the clock to seed random number generator, but pass it into # dismod_at using the :ref:`option table` : # {xrst_spell_off} # {xrst_code py} import time random_seed = int( time.time() ) # {xrst_code} # {xrst_spell_on} # # Source Code # *********** # Given the problem parameters define above, below is the rest of the # source code for this example: # {xrst_literal # BEGIN PYTHON # END PYTHON # } # # {xrst_end user_const_value.py}