------------------------------------------- lines 5-105 of file: example/user/csv2db.py ------------------------------------------- # {xrst_begin user_csv2db.py} # {xrst_spell # mtall # } # {xrst_comment_ch #} # # csv2db_command: Example and Test # ################################ # # Using This Example # ****************** # See :ref:`user_example@Run One Example` for instructions # on running just this example. # After doing that, one can run the command # :: # # python/bin/dismodat.py build/example/user/example.db # # To generate the csv files corresponding to the example database. # One can then inspect the csv files in the ``build/example/user`` # to see all the relevant information. # # Discussion # ********** # The following describes the mode and data for this example: # # rate_true # ********* # The true value for the rates, used to simulate the data, # are constant w.r.t age and time and are given by: # {xrst_literal # BEGIN RATE_TRUE # END RATE_TRUE # } # # P # * # The notation :math:`P` is used for prevalence. # The initial prevalence at age zero is zero; i.e. :math:`P(0) = 0`. # We use :math:`S(a)` (:math:`C(a)`) for the susceptible # (with condition) fraction of the initial population. # The true prevalence :math:`P(a) = C(a) / [S(a) + C(a)]` # is solved for using the ODE: # # .. math:: # :nowrap: # # \begin{eqnarray} # S(0) & = & 1 \\ # C(0) & = & 0 \\ # S'(a) & = & - \iota S(a) + \rho C(a) - \omega S(a) \\ # C'(a) & = & + \iota S(a) - \rho C(a) - \omega C(a) - \chi C(a) # \end{eqnarray} # # Rate Grids # ********** # The value of omega is modeled as know and equal to the # value of # :ref:`csv2db_command@integrand@mtall` # corresponding to the age-time intervals: # {xrst_literal # BEGIN INTERVALS # END INTERVALS # } # The non-zero rates (iota, rho, chi) are modeled as unknown and piecewise # bilinear with the same grid points. # # Data # **** # The Data is simulated, # without any noise, for the following integrands: # :ref:`csv2db_command@integrand@remission` , # :ref:`csv2db_command@integrand@mtexcess` , # :ref:`csv2db_command@integrand@prevalence` . # Note that the model for the noise in the measurement # :ref:`csv2db_command@meas_std` # is a 10 percent coefficient of variation. # See the file # :ref:`db2csv_command@data.csv` output by the # db2csv command. # # Predictions # *********** # The :ref:`csv2db_command@Predictions` are in the file # :ref:`db2csv_command@predict.csv` output by the # db2csv command. # # mtall # ***** # The omega constraints correspond to # :ref:`csv2db_command@integrand@mtall` data. # As a check, we include the mtall data with hold_out equal to one. # # Source Code # *********** # {xrst_literal # BEGIN PYTHON # END PYTHON # } # # {xrst_end user_csv2db.py}