-------------------------------------------- lines 5-107 of file: example/user/sim_log.py -------------------------------------------- # {xrst_begin user_sim_log.py} # {xrst_comment_ch #} # # Simulating Data with Log Transformed Distribution # ################################################# # # See Also # ******** # :ref:`user_data_sim.py-name` # # Example Parameters # ****************** # The following values are used to simulate the data # {xrst_spell_off} # {xrst_code py} number_simulate = 2000 iota_true = 0.01 meas_value_global = iota_true * 1.5 eta_global = iota_true * 1e-3 meas_std_global = meas_value_global * 0.25 gamma_global = meas_value_global * 0.25 # {xrst_code} # {xrst_spell_on} # Model # ***** # The only non-zero model variable for this example is # the rate of incidence for the world which is constant in age and time. # # Data # **** # There is only one data point for this example and it's integrand is # :ref:`avg_integrand@Integrand, I_i(a,t)@Sincidence` . # This data has a log transformed distribution with mean *iota_true* , # offset *eta_global* , and standard deviation # *meas_std_global* . # # Covariate Multiplier # ******************** # For this example there is one covariate multiplier. # It is a :ref:`mulcov_table@mulcov_type@meas_noise` multiplier # and the corresponding covariate value is one. # # Notation # ******** # # .. list-table:: # :widths: auto # # * - :math:`y` # - is the measurement value, *meas_value_global* # * - :math:`\mu` # - mean of the data, *iota_true* # * - :math:`\eta` # - offset in log transform, *eta_global* # * - :math:`\Delta` # - data measurement error, *meas_std_global* # * - :math:`\gamma` # - meta regression error, *gamma_global* # * - :math:`n` # - number of simulated data values, # :ref:`simulate_command@number_simulate` # * - :math:`z_i` # - *i*-th simulate data for :math:`i = 1, \ldots , n` # # delta # ***** # The transformed standard deviation # :ref:`delta` # is given by # # .. math:: # # \delta = \log( y + \eta + \sigma ) - \log(y + \eta) # # sigma # ***** # For this example we use the # :ref:`data_like@Adjusted Standard Deviation, sigma_i(theta)@add_std_scale_none` # option in the definition of the adjusted standard deviation # :ref:`sigma` # :math:`\sigma`; i.e., # # .. math:: # # \sigma = \Delta + \gamma # # Simulations # *********** # The offset log transform of each simulated measurement :math:`z_i` has # the following Gaussian distribution: # # .. math:: # # \log( z_i + \eta ) - \log( \mu + \eta ) \sim N(0, \delta^2 ) # # Source Code # *********** # {xrst_literal # BEGIN PYTHON # END PYTHON # } # # {xrst_end user_sim_log.py}