-------------------------------------------- lines 5-78 of file: example/user/binomial.py -------------------------------------------- # {xrst_begin user_binomial.py} # {xrst_comment_ch #} # # Fitting Binomial Data Example # ############################# # # Iota # **** # There is only one grid point in the parent and child smoothing # for iota, hence they are constant with respect to age and time. # # Parent # ====== # The value *iota_true* # is the simulated true rate for *iota* # for both the parent and two child nodes. # A uniform prior is used for the parent rate with # *iota_parent_true* /100 as a lower limit, # and ``1`` as the upper limit. # # Child # ===== # The *iota* # :ref:`model_variables@Random Effects, u@Child Rate Effects` # are simulated with value zero. # They are fit using # a Gaussian prior with a mean zero and standard deviation 0.1. # # Other Rates # *********** # The :ref:`rate_table@parent_smooth_id` and # :ref:`rate_table@child_smooth_id` are null for the other rates; i.e.,\ # the other rates are zero. # # Data # **** # # Integrand # ========= # All of the data is for the prevalence integrand. # Since *iota* is constant, and the other rates are zero, # the true prevalence is :math:`1 - \exp( - iota * age )` . # # meas_value # ========== # The prevalence data is simulate using a # binomial distribution divided by its sample size. # The mean of the binomial distribution # is the sample size times the true prevalence. # # Sample Size # =========== # The sample size for each data point is chosen as follows: # {xrst_literal # # BEGIN_SAMPLE_SIZE # # END_SAMPLE_SIZE # } # # Density # ======= # If the count, corresponding to the measured value, is greater than or equal # a threshold, a Gaussian approximation is used, otherwise the # :ref:`density_table@density_name@binomial` density is used. # Note that the approximation seems to work well even when the # threshold is zero. # # Source Code # *********** # {xrst_literal # BEGIN PYTHON # END PYTHON # } # # {xrst_end user_binomial.py}