initialize_nlcm_doubletree: Initialize the variational Bayesian algorithm for nested...

View source: R/initialize.R

initialize_nlcm_doubletreeR Documentation

Initialize the variational Bayesian algorithm for nested latent class models with double-tree structured shrinkage

Description

NB: 1) does this work with missing CODs in all domains (not just the target domain); 2) does this work with partially-known labels in the target domain (not all are missing) Organize intermediate variables,

  1. target_id.

  2. who are in the target domain

  3. who are the people from cause c and domain g

  4. check the mapping from integers to leaves; same for all the nodes

Usage

initialize_nlcm_doubletree(
  Y,
  A,
  leaf_ids_units,
  leaf_ids,
  leaf_ids_nodes,
  ancestors,
  v_units,
  h_pau,
  levels,
  vi_params,
  hyperparams,
  hyper_fixed,
  random_init,
  random_init_vals
)

Arguments

Y

matrix of binary observations; preprocessed data from design_doubletree() stored in resB$Y. NA missing data is allowed, which in the nested latent class model will be treated as missing at random.

A

a list of two square binary matrices: the first is p1 by p1, with 1s in each row indicating the ancestors (the node in that row included) in the first tree (cause tree). The second element is p2 by p2, the counterpart for the second tree (domain tree.) The row names of each square matrix are the orders of the trees.

leaf_ids_units

unit ids nested in each leaf node; a list of two elements (for tree1 and tree2); each element is again a list - each of its element is associated with a leaf in a tree and contains the subject ids in that leaf node.

leaf_ids

a list of length two; each element is a vector of character strings indicating the leaf label an observation is coming from. For the first element, there might be missing values, including unobserved leaf label in tree1.

leaf_ids_nodes

leaf descendants; a list of two elements (for tree1 and tree2); for each element, the leaf descendants for each internal or leaf nodes (a list)

ancestors

a list of two elements (for tree1 and tree2); Each element is a list, with each element containing numeric vector of ancestor nodes - the length is equal to the number of leaves in a tree.

v_units

a list of two elements (for tree1 and tree2) - both are of length N; each element is a vector of integers indicating the leaf ids. In the first element, there might be missing entries, indicating the missing leaf label in tree1.

h_pau

edge weights; a list of two elements (for tree1 and tree2); a numeric vector (length = #nodes) the edge length between a node and its parent node. The root node has no parent, we set the edge length toward root node to 1.

levels

a list of two elements (for tree1 and tree2); For each element, a numeric vector of integers from 1 to Fg1 for the first tree (or Fg2 for the second tree), indicating for each node which set of hyperparameters to use. The levels are pre-specified, not estimated. We recommend at least five nodes in any level for learning the slab variance parameters.

vi_params

the list of variational parameters.

hyperparams

the list of hyperparameters

hyper_fixed

a list of fixed hyperparameters: the number of classes K; ⁠(a1,b1)⁠ and ⁠(a2,b2)⁠ are the Beta hyperparameters for selecting slab components; dmat the hyperparameters in the Dirichlet distributions for each domain (i.e., each leaf of tree2.)

random_init

logical; TRUE for adding additional variability to the initial values; This is a must if the algorithm needs multiple random starts to choose the best converged values. Currently the logit(0.5) of response probability may produce zero, The sd_frac is a fraction of the logit value, which may not be producing any additional randomness.

random_init_vals

NB: fill out specific elements; this is to be done.

Value

a list of two elements:vi_params,hyperparams with initial values for the nested latent class model with double tree shrinkage. target_id and scenario are both added (use ?doubletree to see meanings of scenarios).


zhenkewu/doubletree documentation built on Oct. 21, 2023, 7:04 a.m.