----------------------------------------------- lines 5-80 of file: example/user/change_grid.py ----------------------------------------------- # {xrst_begin user_change_grid.py} # {xrst_comment_ch #} # # Remove an Age or Time From a Smoothing # ###################################### # # Purpose # ******* # This examples uses SQL commands to modify a data base. # To be specific, it removes one of the age points from a smoothing grid. # # Age Table # ********* # The :ref:`age_table-name` for this example is specified by the code # :: # # age_list = [0, 1, 20, 30, 40, 50, 60, 70, 80, 90, 100 ] # # Time Table # ********** # The :ref:`time_table-name` is specified by # :: # # time_list = [ 1960, 1995 ] # # Parent Smoothing # **************** # The original parent smoothing table contains all of the age and time points. # # Value Prior # =========== # The value prior at each (age, time) pair is log-Gaussian with # lower limit 1 ``e-2`` * *iota_mean* , # upper limit 1 *e* +2* ``iota_mean`` , # mean *iota mean* , # standard deviation *iota_mean* , # and the offset in the log transform 1 ``e-3`` * *iota_mean* . # # Difference Prior # ================ # The forward difference prior at each (age, time) pair is log-Gaussian with # no lower limit, # no upper limit, # mean zero, # standard deviation 1.0 , # and the offset in the log transform ``1e-6`` . # # Change Parent Smoothing # *********************** # Note that the original age grid has 11 points. # The last age point, and all the corresponding (age, time) pairs # are removed from the smoothing grid with the following SQL commands: # :: # # UPDATE smooth SET n_age = 10 WHERE smooth_id == 0; # UPDATE smooth_grid SET smooth_id = WHERE smooth_id == 0 AND age_id == 10; # # We refer to this as the modified smoothing. # # Fit # *** # The only variables in this example are the parent rates for *iota* . # Hence the number of variables in the :ref:`var_table-name` should be the number # of grid points in the modified smoothing; i.e., 20. # There is no data for this example. # Hence the optimal fit is to have *iota* equal to *iota_mean* # for all the (age, time) paris in the modified smoothing. # # Source Code # *********** # {xrst_literal # BEGIN PYTHON # END PYTHON # } # # {xrst_end user_change_grid.py}