Package: baker 1.0.3

Zhenke Wu

baker: "Nested Partially Latent Class Models"

Provides functions to specify, fit and visualize nested partially-latent class models ( Wu, Deloria-Knoll, Hammitt, and Zeger (2016) <doi:10.1111/rssc.12101>; Wu, Deloria-Knoll, and Zeger (2017) <doi:10.1093/biostatistics/kxw037>; Wu and Chen (2021) <doi:10.1002/sim.8804>) for inference of population disease etiology and individual diagnosis. In the motivating Pneumonia Etiology Research for Child Health (PERCH) study, because both quantities of interest sum to one hundred percent, the PERCH scientists frequently refer to them as population etiology pie and individual etiology pie, hence the name of the package.

Authors:Zhenke Wu [cre, aut, cph], Scott Zeger [aut], John Muschelli [ctb], Irena Chen [ctb]

baker_1.0.3.tar.gz
baker_1.0.3.tar.gz(r-4.5-noble)baker_1.0.3.tar.gz(r-4.4-noble)
baker_1.0.3.tgz(r-4.4-emscripten)baker_1.0.3.tgz(r-4.3-emscripten)
baker.pdf |baker.html
baker/json (API)
NEWS

# Install 'baker' in R:
install.packages('baker', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/zhenkewu/baker/issues

Pkgdown site:https://zhenkewu.com

Uses libs:
  • jags– Just Another Gibbs Sampler for Bayesian MCMC
  • c++– GNU Standard C++ Library v3
Datasets:

jagscpp

3.02 score 21 scripts 204 downloads 54 exports 157 dependencies

Last updated 11 months agofrom:0ac898ef37. Checks:OK: 2. Indexed: no.

TargetResultDate
Doc / VignettesOKDec 26 2024
R-4.5-linuxOKDec 26 2024

Exports:assign_modelbeta_parms_from_quantilesbeta_plotbin2deccheck_dir_createclean_combine_subsitesclean_perch_datacombine_data_nplcmcompute_logOR_single_causedelete_start_withexpitextract_data_rawget_individual_dataget_individual_predictionget_top_patternHhas_non_basisI2symbImat2catis_jags_folderis_length_all_oneline2userlogitlogsumexpmake_filenamemake_foldernamemake_listmake_meas_objectmake_templatemarg_Hmatch_causemerge_listsmy_reordernplcmnplcm_read_folderoverall_uniformplot_check_common_patternplot_check_pairwise_SLORDplot_logORmatread_meas_objectrvberns_date_Etis_date_FPRshow_depshow_individualsimulate_nplcmsoftmaxsubset_data_nplcm_by_indexsummarize_BrSsummarize_SSsymb2Itsbunfactorunique_cause

Dependencies:abindashbackportsbase64encbinombitopsbootbroombslibcachemcarcarDataclasscliclustercodacolorspacecommonmarkcorrplotcowplotcpp11crayoncvToolsdata.tableDEoptimRDerivdeSolvedigestdiptestdoBydplyre1071fansifarverfastmapfdafdsflexmixFNNfontawesomeforcatsFormulafpcfsgenericsGGallyggfortifyggplot2ggpubrggrepelggsciggsignifggstatsgluegridExtragtablehdrcdehmshtmltoolshttpuvisobandjquerylibjsonlitekernlabKernSmoothkslabelinglaekenlaterlatticelifecyclelme4lmtestlocfitlubridatemagrittrMASSMatrixMatrixModelsmclustmemoisemgcvmicrobenchmarkmimeminqamodelrmodeltoolsmulticoolmunsellmvbutilsmvtnormNADAnlmenloptrnnetnumDerivpatchworkpbkrtestpcaPPperrypillarpkgconfigplsplyrpolynomprabcluspracmaprettyunitsprogresspromisesproxypurrrquantregR2jagsR2WinBUGSR6rainbowrangerrappdirsRColorBrewerRcppRcppArmadilloRcppEigenRCurlreshape2rjagsrlangrobCompositionsrobustbaserobustHDrrcovrstatixsassscalesshinyshinydashboardshinyFilessourcetoolsspSparseMstringistringrsurvivaltibbletidyrtidyselecttimechangetruncnormutf8vcdvctrsVIMviridisLitewithrxtablezCompositionszoo

Vignettes for baker: An R package for fitting nested partially latent class models

Rendered frombaker_demo.Rmdusingknitr::rmarkdownon Dec 26 2024.

Last update: 2022-02-02
Started: 2022-02-02

Readme and manuals

Help Manual

Help pageTopics
add likelihood for a BrS measurement slice among cases (conditional dependence)add_meas_BrS_case_Nest_Slice
add likelihood for a BrS measurement slice among cases (conditional dependence)add_meas_BrS_case_Nest_Slice_jags
add likelihood component for a BrS measurement slice among casesadd_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags
add likelihood component for a BrS measurement slice among casesadd_meas_BrS_case_NoNest_reg_Slice_jags
add a likelihood component for a BrS measurement slice among cases (conditional independence)add_meas_BrS_case_NoNest_Slice
add a likelihood component for a BrS measurement slice among cases (conditional independence)add_meas_BrS_case_NoNest_Slice_jags
add likelihood for a BrS measurement slice among controls (conditional independence)add_meas_BrS_ctrl_Nest_Slice
add a likelihood component for a BrS measurement slice among controlsadd_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags
add a likelihood component for a BrS measurement slice among controlsadd_meas_BrS_ctrl_NoNest_reg_Slice_jags
add a likelihood component for a BrS measurement slice among controls (conditional independence)add_meas_BrS_ctrl_NoNest_Slice
add parameters for a BrS measurement slice among cases and controlsadd_meas_BrS_param_Nest_reg_Slice_jags
add parameters for a BrS measurement slice among cases and controls (conditional dependence)add_meas_BrS_param_Nest_Slice
add parameters for a BrS measurement slice among cases and controls (conditional dependence)add_meas_BrS_param_Nest_Slice_jags
add parameters for a BrS measurement slice among cases and controlsadd_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags
add parameters for a BrS measurement slice among cases and controlsadd_meas_BrS_param_NoNest_reg_Slice_jags
add parameters for a BrS measurement slice among cases and controls (conditional independence)add_meas_BrS_param_NoNest_Slice
add parameters for a BrS measurement slice among cases and controls (conditional independence)add_meas_BrS_param_NoNest_Slice_jags
add subclass indicators for a BrS measurement slice among cases and controls (conditional independence)add_meas_BrS_subclass_Nest_Slice
add likelihood for a SS measurement slice among cases (conditional independence)add_meas_SS_case
add parameters for a SS measurement slice among cases (conditional independence)add_meas_SS_param
convert one column data frame to a vectoras.matrix_or_vec
Interpret the specified model structureassign_model
baker: *B*ayesian *A*nalytic *K*it for *E*tiology *R*esearchbaker
Pick parameters in the Beta distribution to match the specified rangebeta_parms_from_quantiles
Plot beta densitybeta_plot
Convert a 0/1 binary-coded sequence into decimal digitsbin2dec
check existence and create folder if non-existentcheck_dir_create
Combine subsites in raw PERCH data setclean_combine_subsites
Clean PERCH dataclean_perch_data
combine multiple data_nplcm (useful when simulating data from regression models)combine_data_nplcm
Calculate marginal log odds ratioscompute_logOR_single_cause
compute positive rates for nested model with subclass mixing weights that are the same across 'Jcause' classes for each person (people may have different weights.)compute_marg_PR_nested_reg
compute positive rates for nested model with subclass mixing weights that are the same across 'Jcause' classes for each person (people may have different weights.)compute_marg_PR_nested_reg_array
create regressor summation equation used in regression for etiologycreate_bugs_regressor_Eti
create regressor summation equation used in regression for FPRcreate_bugs_regressor_FPR
Simulated dataset that is structured in the format necessary for an 'nplcm()' without regressiondata_nplcm_noreg
Simulated dataset that is structured in the format necessary for an 'nplcm()' with regressiondata_nplcm_reg_nest
Deletes a pattern from the start of a string, or each of a vector of strings.delete_start_with
Make etiology design matrix for dates with R format.dm_Rdate_Eti
Make FPR design matrix for dates with R format.dm_Rdate_FPR
expit functionexpit
Import Raw PERCH Data 'extract_data_raw' imports and converts the raw data to analyzable formatextract_data_raw
Obtain coverage status from a result folderget_coverage
Obtain direct bias that measure the discrepancy of a posterior distribution of pie and a true pie.get_direct_bias
get fitted mean for nested model with subclass mixing weights that are the same among casesget_fitted_mean_nested
get model fitted mean for conditional independence modelget_fitted_mean_no_nested
get individual dataget_individual_data
get individual prediction (Bayesian posterior)get_individual_prediction
get index of latent statusget_latent_seq
get marginal TPR and FPR for nested modelget_marginal_rates_nested
get marginal TPR and FPR for no nested modelget_marginal_rates_no_nested
Obtain Integrated Squared Aitchison Distance, Squared Bias and Variance (both on Central Log-Ratio transformed scale) that measure the discrepancy of a posterior distribution of pie and a true pie.get_metric
get etiology samples by names (no regression)get_pEti_samp
get the plotting positions (numeric) for the fitted means; 3 positions for each cellget_plot_num
get a list of measurement index where to look for dataget_plot_pos
Obtain posterior standard deviation from a result folderget_postsd
get top patterns from a slice of bronze-standard measurementget_top_pattern
Shannon entropy for multivariate discrete dataH
test if a formula has terms not created by [s_date_Eti() or 's_date_FPR()'has_non_basis
Convert 0/1 coding to pathogen/combinationsI2symb
Convert a matrix of binary indicators to categorical variablesImat2cat
Initialize individual latent status (for 'JAGS')init_latent_jags_multipleSS
insert distribution for latent status code chunk into .bug fileinsert_bugfile_chunk_noreg_etiology
Insert measurement likelihood (without regression) code chunks into .bug model fileinsert_bugfile_chunk_noreg_meas
insert etiology regression for latent status code chunk into .bug file; discrete predictorsinsert_bugfile_chunk_reg_discrete_predictor_etiology
Insert measurement likelihood (with regression; discrete) code chunks into .bug model fileinsert_bugfile_chunk_reg_discrete_predictor_nonest_meas
insert etiology regression for latent status code chunk into .bug fileinsert_bugfile_chunk_reg_etiology
Insert measurement likelihood (nested model+regression) code chunks into .bug model fileinsert_bugfile_chunk_reg_nest_meas
Insert measurement likelihood (with regression) code chunks into .bug model fileinsert_bugfile_chunk_reg_nonest_meas
Check if covariates are discreteis_discrete
check if the formula is intercept onlyis_intercept_only
See if a result folder is obtained by JAGSis_jags_folder
check if a list has elements all of length oneis_length_all_one
Test for 'try-error' classis.error
Run 'JAGS' from Rjags2_baker
convert line to user coordinatesline2user
load an object from .RDATA fileloadOneName
logit functionlogit
calculate pairwise log odds ratioslogOR
log sum exp tricklogsumexp
Get position to store in data_nplcm$Mobs:lookup_quality
Create new file namemake_filename
Create new folder namemake_foldername
Takes any number of R objects as arguments and returns a list whose names are derived from the names of the R objects.make_list
Make measurement slicemake_meas_object
Make a list with numbered namesmake_numbered_list
make a mapping template for model fittingmake_template
Shannon entropy for binary datamarg_H
Match latent causes that might have the same combo but different specificationsmatch_cause
For a list of many sublists each of which has matrices as its member, we combine across the many sublists to produce a final listmerge_lists
Reorder the measurement dimensions to match the order for displaymy_reorder
convert 'NA' to '.'NA2dot
Fit nested partially-latent class models (highest-level wrapper function)nplcm
Fit nested partially-latent class model (low-level)nplcm_fit_NoReg
Fit nested partially-latent class model with regression (low-level)nplcm_fit_Reg_discrete_predictor_NoNest
Fit nested partially-latent class model with regression (low-level)nplcm_fit_Reg_Nest
Fit nested partially-latent class model with regression (low-level)nplcm_fit_Reg_NoNest
Read data and other model information from a folder that stores model results.nplcm_read_folder
Convert 'NULL' to zero.null_as_zero
order latent status by posterior meanorder_post_eti
specify overall uniform (symmetric Dirichlet distribution) for etiology prioroverall_uniform
parse regression components (either false positive rate or etiology regression) for fitting npLCM; Only use this when formula is not 'NULL'.parse_nplcm_reg
pathogens and their categories in PERCH study (virus or bacteria)pathogen_category_perch
Hypothetical pathogens and their categories (virus or bacteria)pathogen_category_simulation
Plot bronze-standard (BrS) panelplot_BrS_panel
visualize the PERCH etiology regression with a continuous covariateplot_case_study
Posterior predictive checking for the nested partially class models - frequent patterns in the BrS data. (for multiple folders)plot_check_common_pattern
Posterior predictive checking for nested partially latent class models - pairwise log odds ratio (only for bronze-standard data)plot_check_pairwise_SLORD
visualize the etiology regression with a continuous covariateplot_etiology_regression
visualize the etiology estimates for each discrete levelsplot_etiology_strat
plotting the labels on the left margin for panels plotplot_leftmost
Visualize pairwise log odds ratios (LOR) for data that are available in both cases and controlsplot_logORmat
Plot three-panel figures for nested partially-latent model resultsplot_panels
Plot etiology (pie) panelplot_pie_panel
Plot silver-standard (SS) panelplot_SS_panel
visualize the subclass weight regression with a continuous covariateplot_subwt_regression
'plot.nplcm' plot the results from 'nplcm()'.plot.nplcm
'print.nplcm' summarizes the results from 'nplcm()'.print.nplcm
Compact printing of 'nplcm()' model fitsprint.summary.nplcm.no_reg
Compact printing of 'nplcm()' model fitsprint.summary.nplcm.reg_nest
Compact printing of 'nplcm()' model fitsprint.summary.nplcm.reg_nest_strat
Compact printing of 'nplcm()' model fitsprint.summary.nplcm.reg_nonest
Compact printing of 'nplcm()' model fitsprint.summary.nplcm.reg_nonest_strat
Read measurement slicesread_meas_object
Sample a vector of Bernoulli variables.rvbern
Make Etiology design matrix for dates with R format.s_date_Eti
Make false positive rate (FPR) design matrix for dates with R format.s_date_FPR
Set true positive rate (TPR) prior ranges for bronze-standard (BrS) dataset_prior_tpr_BrS_NoNest
Set true positive rate (TPR) prior ranges for silver-standard data.set_prior_tpr_SS
Stratification setup by covariatesset_strat
Show function dependenciesshow_dep
get an individual's data from the output of 'clean_perch_data()'show_individual
Simulate Bronze-Standard (BrS) Datasimulate_brs
Simulate Latent Status:simulate_latent
Simulate data from nested partially-latent class model (npLCM) familysimulate_nplcm
Simulate Silver-Standard (SS) Datasimulate_ss
softmaxsoftmax
subset data from the output of 'clean_perch_data()'subset_data_nplcm_by_index
summarize bronze-standard datasummarize_BrS
silver-standard data summarysummarize_SS
'summary.nplcm' summarizes the results from 'nplcm()'.summary.nplcm
get symmetric difference of months from two vector of R-format datessym_diff_month
Convert names of pathogen/combinations into 0/1 codingsymb2I
generate stick-breaking prior (truncated) from a vector of random probabilitiestsb
Convert factor to numeric without losing information on the labelunfactor
get unique causes, regardless of the actual order in combounique_cause
Get unique month from Dateunique_month
Visualize matrix for a quantity measured on cases and controls (a single number)visualize_case_control_matrix
visualize trend of pathogen observation rate for NPPCR data (both cases and controls)visualize_season
Write .bug model file for model without regressionwrite_model_NoReg
Write .bug model file for regression model without nested subclasseswrite_model_Reg_discrete_predictor_NoNest
Write '.bug' model file for regression model WITH nested subclasseswrite_model_Reg_Nest
Write .bug model file for regression model without nested subclasseswrite_model_Reg_NoNest
function to write bugs model (copied from R2WinBUGS)write.model