merge_H_Q: Merge latent state profile matrix (H_star) and Q matrix

Description Usage Arguments Value Examples

Description

This function

Usage

1
2
3
4
5
6
7
8
9
merge_H_Q(
  H_star_redun,
  mylist,
  t,
  Q,
  VERBOSE = FALSE,
  z_pseudo = NULL,
  skip_Q = FALSE
)

Arguments

H_star_redun

A binary matrix of rows t_max+3 by m_max; It may be redundant because it has rows corresponding to empty pseudo-clusters, and if the matrix has at least one non-zero element, the zero columns indicate inactive latent states

mylist

Cluster labels; A vector of length t_max+3 comprised of integers that need not be consecutive.

t

The number of non-empty pseudo-clusters

Q

The m_max by L Q matrix

VERBOSE

Default to FALSE: no print of the merged matrices; Otherwise set to TRUE.

z_pseudo

Default is NULL. A vector of pseudo-cluster indicators to be merged into scientific cluster indicators z_sci.

skip_Q

Default is FALSE - merge the rows of Q that correspond to partner states; Set to TRUE if Q is given in which case only rows of H_star_redun will be merged (keep the zero columns in H_star_redun, and not merging partner states).

Value

A list comprised of two elements named: H_star_merge and Q_merge and z_sci if z_pseudo is provided.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# the third latent state is inactive among non-empty pseudo-clusters;
# the 2nd and 4th latent states are partners.
# merge 1st and 2nd pseudo-clusters.
 H_star_redun <- matrix(c(0,1,0,1,
                          0,1,0,1,
                          1,0,0,0,
                          0,0,0,0,
                          0,0,0,0,
                          0,0,0,0,
                          0,0,0,0),nrow=7,ncol=4,byrow=TRUE)
mylist <- c(1,2,3,5,0,0,0)
t <- 4
Q <- simulate_Q(4,100,p=0.1)
z_pseudo <- c(1,1,3,5,2,2,2,1,3,3,5,1,2,2,1)
# Q is unknown and sampled
merge_H_Q(H_star_redun,mylist,t,Q,TRUE,z_pseudo)
# Q is known:
merge_H_Q(H_star_redun,mylist,t,Q,TRUE,z_pseudo,TRUE)

zhenkewu/rewind documentation built on Sept. 9, 2020, 3:40 p.m.