make_template: make a mapping template for model fitting

View source: R/utils.R

make_templateR Documentation

make a mapping template for model fitting


make_template creates a mapping matrix (binary values). Each pathogen in a measurement slice (e.g., nasal-pharyngeal PCR test) is mapped to inform one category of latent status. All the possible categories (e.g., causes of pneumonia) remain the same regardless of the measurement slice used (e.g., NPPCR or BCX).


make_template(patho, cause_list)



A vector of pathogen names for a particular measurement slice. patho must be a substring of some elements in cause_list, e.g., "PNEU" is a substring of "PNEU_VT13". Also see Examples for this function.


A vector of characters; Potential categories of latent statuses.


The first argument has to be character substrings from the second argument. For example, the two arguments can respectively be "A" and "A_1", or "A" and "A+B".The second argument can have character strings not matched in the first argument. If so, it means some causes of diseases are not directly measured in the current measurement slice. For each element of patho, the function matches from the start of the strings of cause_list. Therefore, make sure that latent statuses from the same family (e.g., "PNEU_VT13" and "PNEU_NOVT13") need to start with the same family name (e.g., "PNEU") followed by subcategories (e.g., "_VT13" and "_NOVT13").


a mapping from patho to cause_list. NROW = length(cause_list)+1; NCOL = length(patho). This value is crucial in model fitting to determine which measurements are informative of a particular category of latent status.


cause_list <- c("HINF","PNEU_VT13","PNEU_NOVT13","SAUR","HMPV_A_B","FLU_A",
"PARA_1","PARA_3","PARA_4","PV_EV","RHINO","RSV", "ENTRB","TB")

patho_BrS_NPPCR <- c("HINF","PNEU","SAUR","HMPV_A_B","FLU_A","PARA_1",

 cause = c("A","B1","B2","C","A+C","B+C")
 patho = c("A","B","C")
 cause = c("A","B1","B2","C","A+C","B+C","other")
 patho = c("A","B","C")
 cause = c("A","B1","B2","X_B","Y_B","C","A+C","B+C","other")
 patho = c("A","B","C","X_B","Y_B")

zhenkewu/baker documentation built on March 17, 2022, 9:54 p.m.