-------------------------------------------------- lines 5-88 of file: example/user/fit_fixed_both.py -------------------------------------------------- # {xrst_begin user_fit_fixed_both.py} # {xrst_spell # exp # } # {xrst_comment_ch #} # # Fit Fixed First Then Both # ######################### # # Purpose # ******* # This example demonstrates using the commands # # | |tab| ``dismod_at`` *database* ``fit fixed`` # | |tab| ``dismod_at`` *database* ``set start_var fit_var`` # | |tab| ``dismod_at`` *database* ``fit both`` # # This stabilizes the optimization when the ``init`` command # :ref:`init_command@start_var_table` is # far from the optimal fixed effects; see # :ref:`fit_command-name` . # # Discussion # ********** # The following describes the model and data for this example: # # #. The :ref:`age_table-name` has values # ``0.0`` , ``50.0`` , ``100.0`` . # The :ref:`time_table-name` has values # ``1995.0`` , ``2005.0`` , ``2015.0`` . # #. The parent node is North America, the child nodes are # Canada and the United States. # #. The only :ref:`model_variables-name` in this example are # :ref:`rate_table@rate_name@iota` for the parent and the # corresponding random effects for two children. # These rates are modeled as constant with respect to age and # linear between time 1995 and 2015. # The true iota is # # .. csv-table:: # :widths: auto # # 0.01,North America # 0.01 * exp(+0.5),United States # 0.01 * exp(-0.5),Canada # # Note that the random effect for the United States is +0.5 # and for Canada it is -0.5. # #. There are three measurements, one for each node. # All the measurements are at age 50 and time 2000 # (there is no age or time interval for the data points). # The measurement value is exactly equal to the true value of *iota* # for the corresponding node. # The measurement noise is modeled to have a 10 percent coefficient # of variation (even though there is no noise in the actual measurements). # #. The prior for North America is a uniform with mean equal to # the true value for North America divided by 100. This makes the fixed effect # in :ref:`init_command@start_var_table` a poor starting # value. # The prior for Canada and the United States is a Gaussian with mean zero and # standard deviation 100. # The large standard deviation is so that it does not have much effect. # #. The prior for the difference in *iota* between time 1995 # and time 2015 for the children (parent) is a Gaussian (log Gaussian) # with mean zero and standard deviation 0.1. # #. The init command is sets # :ref:`init_command@start_var_table` equal to the # prior mean. # The prior mean for North America (the fixed effect) is far from its # true values and doing a fit fixed obtains a better starting point # for the fit both. # # {xrst_code py} # # {xrst_code} # Source Code # *********** # {xrst_literal # BEGIN PYTHON # END PYTHON # } # # {xrst_end user_fit_fixed_both.py}