continue_cascade_xam

View page source

Example Continuing a Cascade

For this example everything is constant in age and time.

Nodes

The following is a diagram of the node tree for this example. The root_node is n0, the first fit_goal_set is {n3, n4, n2}, the second fit_goal_set is {n5, n6}, and the leaf nodes are {n3, n4, n5, n6}:

            n0
      /-----/\-----\
    n1             (n2)
   /  \            /  \
(n3)  (n4)      [n5]  [n6]

fit_goal_set

first_fit_goal_set  = { 'n3', 'n4', 'n2' }
second_fit_goal_set = { 'n5', 'n6' }

A cascade using the first fit_goal_set is started at node n0. After that finishes, the cascade is continued from node n2 using the second fit_goal_set.

Parallel Processing

This example sets max_number_cpu as an example of parallel processing. The results for nodes n3 and n4 are computed in parallel during the call to cascade_root_node. The results for nodes n5 and n6 are computed in parallel during the call to continue_cascade.

option_all  = {
   'result_dir':     'build/example',
   'root_node_name': 'n0',
   'max_number_cpu':  '2',
}
option_all['root_database'] = option_all['result_dir'] + '/root.db'

see option_all.

Rates

The only non-zero dismod_at rate for this example is iota.

Covariate

There are no covariates for this example.

Simulated Data

rate_true(rate, a, t, n, c)

For rate equal to iota, this is the true value for rate in node n at age a, time t, and covariate values c. The values a, t. c, are not used by this function for this example.

def rate_true(rate, a, t, n, c) :
   iota_true = {
      'n3' : 0.04,
      'n4' : 0.05,
      'n5' : 0.06,
      'n6' : 0.07,
   }
   iota_true['n1'] = (iota_true['n3'] + iota_true['n4']) / 2.0
   iota_true['n2'] = (iota_true['n5'] + iota_true['n6']) / 2.0
   iota_true['n0'] = (iota_true['n1'] + iota_true['n2']) / 2.0
   if rate == 'iota' :
      return iota_true[n]
   return 0.0

y_i

The only simulated integrand for this example is Sincidence which is a direct measurement of iota. This data is simulated without any noise; i.e., the i-th measurement is simulated as y_i = rate_true(‘iota’, None, None, n_i, None) where n_i is the node. The data is modeled as having noise even though there is no simulated noise.

n_i

Data is only simulated for the leaf nodes; i.e., each n_i is in the set { n3, n4, n5, n6 }. Since the data does not have any nose, the data residuals are a measure of how good the fit is for the nodes in the fit goal sets.

Parent Rate Smoothing

This is the iota smoothing used for the fit_node. There are no dage or dtime priors because there is only one age and one time point.

Value Prior

The following is the value prior used for the root_node

      {   'name':    'parent_value_prior',
         'density': 'gaussian',
         'lower':   iota_mean / 10.0,
         'upper':   iota_mean * 10.0,
         'mean':    iota_mean,
         'std':     iota_mean,
         'eta':     iota_mean * 1e-3
      }

The mean and standard deviation are only used for the root_node. The create_shift_db routine replaces them for other nodes.

Child Rate Smoothing

This is the smoothing used for the random effect for each child of the fit_node. There are no dage or dtime priors because there is only one age and one time point in this smoothing.

Value Prior

The following is the value prior used for the children of the fit_node:

      {   'name':    'child_value_prior',
         'density': 'gaussian',
         'mean':    0.0,
         'std':     10.0,
      }

Checking The Fit

The results of the fit are checked by check_cascade_node using the avgint_table that was created by the root_node_db routine. The node_id for each row is replaced by the node_id for the fit being checked. routine uses these tables to check that fit against the truth.

Child

Title

continue_cascade.py

continue_cascade: Python Source Code