Title: | "Nested Partially Latent Class Models" |
---|---|
Description: | 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] |
Maintainer: | Zhenke Wu <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.3 |
Built: | 2024-11-26 06:51:03 UTC |
Source: | CRAN |
add likelihood for a BrS measurement slice among cases (conditional dependence)
add_meas_BrS_case_Nest_Slice(s, Mobs, cause_list, ppd = NULL)
add_meas_BrS_case_Nest_Slice(s, Mobs, cause_list, ppd = NULL)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add likelihood for a BrS measurement slice among cases (conditional dependence)
add_meas_BrS_case_Nest_Slice_jags(s, Mobs, cause_list, ppd = NULL)
add_meas_BrS_case_Nest_Slice_jags(s, Mobs, cause_list, ppd = NULL)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug
code;
the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
regression model with no nested subclasses; discrete predictors
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags( s, Mobs, prior, cause_list, ppd = NULL )
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags( s, Mobs, prior, cause_list, ppd = NULL )
s |
the slice |
Mobs |
See |
prior |
Prior specifications. |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code;
the second is parameters
that stores model parameters introduced by this
plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
regression model with no nested subclasses
add_meas_BrS_case_NoNest_reg_Slice_jags(s, Mobs, prior, cause_list, ppd = NULL)
add_meas_BrS_case_NoNest_reg_Slice_jags(s, Mobs, prior, cause_list, ppd = NULL)
s |
the slice |
Mobs |
See |
prior |
Prior specifications. |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code;
the second is parameters
that stores model parameters introduced by this
plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add a likelihood component for a BrS measurement slice among cases (conditional independence)
add_meas_BrS_case_NoNest_Slice(s, Mobs, cause_list, ppd = NULL)
add_meas_BrS_case_NoNest_Slice(s, Mobs, cause_list, ppd = NULL)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code;
the second is parameters
that stores model parameters introduced by this
plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add a likelihood component for a BrS measurement slice among cases (conditional independence)
add_meas_BrS_case_NoNest_Slice_jags(s, Mobs, prior, cause_list, ppd = NULL)
add_meas_BrS_case_NoNest_Slice_jags(s, Mobs, prior, cause_list, ppd = NULL)
s |
the slice |
Mobs |
See |
prior |
Prior specifications. |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code;
the second is parameters
that stores model parameters introduced by this
plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add likelihood for a BrS measurement slice among controls (conditional independence)
add_meas_BrS_ctrl_Nest_Slice(s, Mobs, cause_list, ppd = NULL)
add_meas_BrS_ctrl_Nest_Slice(s, Mobs, cause_list, ppd = NULL)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
regression model without nested subclasses; discrete
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags( s, Mobs, cause_list, ppd = NULL )
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags( s, Mobs, cause_list, ppd = NULL )
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
regression model without nested subclasses
add_meas_BrS_ctrl_NoNest_reg_Slice_jags(s, Mobs, cause_list, ppd = NULL)
add_meas_BrS_ctrl_NoNest_reg_Slice_jags(s, Mobs, cause_list, ppd = NULL)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add a likelihood component for a BrS measurement slice among controls (conditional independence)
add_meas_BrS_ctrl_NoNest_Slice(s, Mobs, cause_list, ppd = NULL)
add_meas_BrS_ctrl_NoNest_Slice(s, Mobs, cause_list, ppd = NULL)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
regression model with nested subclasses; called by insert_bugfile_chunk_reg_nest_meas
add_meas_BrS_param_Nest_reg_Slice_jags( s, Mobs, prior, cause_list, FPR_formula = NULL )
add_meas_BrS_param_Nest_reg_Slice_jags( s, Mobs, prior, cause_list, FPR_formula = NULL )
s |
the slice |
Mobs |
See |
prior |
Prior specifications. |
cause_list |
the list of causes in |
FPR_formula |
False positive regression formula for slice s of BrS data.
Check |
a list of two elements: the first is plug
, the .bug code;
the second is parameters
that stores model parameters introduced by
this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add parameters for a BrS measurement slice among cases and controls (conditional dependence)
add_meas_BrS_param_Nest_Slice(s, Mobs, cause_list)
add_meas_BrS_param_Nest_Slice(s, Mobs, cause_list)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add parameters for a BrS measurement slice among cases and controls (conditional dependence)
add_meas_BrS_param_Nest_Slice_jags(s, Mobs, cause_list)
add_meas_BrS_param_Nest_Slice_jags(s, Mobs, cause_list)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
regression model with no nested subclasses; discrete
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags( s, Mobs, prior, cause_list )
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags( s, Mobs, prior, cause_list )
s |
the slice |
Mobs |
See |
prior |
Prior specifications. |
cause_list |
the list of causes in |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
regression model with no nested subclasses
add_meas_BrS_param_NoNest_reg_Slice_jags( s, Mobs, prior, cause_list, FPR_formula )
add_meas_BrS_param_NoNest_reg_Slice_jags( s, Mobs, prior, cause_list, FPR_formula )
s |
the slice |
Mobs |
See |
prior |
Prior specifications. |
cause_list |
the list of causes in |
FPR_formula |
False positive regression formula for slice s of BrS data.
Check |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add parameters for a BrS measurement slice among cases and controls (conditional independence)
add_meas_BrS_param_NoNest_Slice(s, Mobs, cause_list)
add_meas_BrS_param_NoNest_Slice(s, Mobs, cause_list)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add parameters for a BrS measurement slice among cases and controls (conditional independence)
add_meas_BrS_param_NoNest_Slice_jags(s, Mobs, prior, cause_list)
add_meas_BrS_param_NoNest_Slice_jags(s, Mobs, prior, cause_list)
s |
the slice |
Mobs |
See |
prior |
Prior specifications. |
cause_list |
the list of causes in |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
,
add_meas_SS_param()
add subclass indicators for a BrS measurement slice among cases and controls (conditional independence)
add_meas_BrS_subclass_Nest_Slice(s, Mobs, cause_list, ppd = NULL, reg = NULL)
add_meas_BrS_subclass_Nest_Slice(s, Mobs, cause_list, ppd = NULL, reg = NULL)
s |
the slice |
Mobs |
See |
cause_list |
the list of causes in |
ppd |
Default is NULL; Set to TRUE for enabling posterior predictive checking. |
reg |
Default is NULL; set to TRUE if doing regression (double index of subclass weights: subject and subclass) |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_SS_case()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_SS_case()
,
add_meas_SS_param()
add likelihood for a SS measurement slice among cases (conditional independence)
add_meas_SS_case(nslice, Mobs, prior, cause_list)
add_meas_SS_case(nslice, Mobs, prior, cause_list)
nslice |
the total number of SS measurement slices |
Mobs |
see |
prior |
see |
cause_list |
the list of causes in |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_param()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_param()
add parameters for a SS measurement slice among cases (conditional independence)
add_meas_SS_param(nslice, Mobs, prior, cause_list)
add_meas_SS_param(nslice, Mobs, prior, cause_list)
nslice |
the total number of SS measurement slices |
Mobs |
see |
prior |
see |
cause_list |
the list of causes in |
a list of two elements: the first is plug
, the .bug code; the second is parameters
that stores model parameters introduced by this plugged measurement slice
Other likelihood specification functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
Other plug-and-play functions:
add_meas_BrS_case_Nest_Slice_jags()
,
add_meas_BrS_case_Nest_Slice()
,
add_meas_BrS_case_NoNest_Slice_jags()
,
add_meas_BrS_case_NoNest_Slice()
,
add_meas_BrS_case_NoNest_reg_Slice_jags()
,
add_meas_BrS_case_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_ctrl_Nest_Slice()
,
add_meas_BrS_ctrl_NoNest_Slice()
,
add_meas_BrS_ctrl_NoNest_reg_Slice_jags()
,
add_meas_BrS_ctrl_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_param_Nest_Slice_jags()
,
add_meas_BrS_param_Nest_Slice()
,
add_meas_BrS_param_Nest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice_jags()
,
add_meas_BrS_param_NoNest_Slice()
,
add_meas_BrS_param_NoNest_reg_Slice_jags()
,
add_meas_BrS_param_NoNest_reg_discrete_predictor_Slice_jags()
,
add_meas_BrS_subclass_Nest_Slice()
,
add_meas_SS_case()
convert one column data frame to a vector
as.matrix_or_vec(x)
as.matrix_or_vec(x)
x |
an one-column data.frame |
JAGS cannot accept a data frame with one column; This function converts it to a vector, which JAGS will allow.
a vector
assign_model
translates options specified by a user (e.g., in
model_options
) into information that can be understood by baker
.
assign_model(model_options, data_nplcm, silent = TRUE)
assign_model(model_options, data_nplcm, silent = TRUE)
model_options |
See |
data_nplcm |
Data. See |
silent |
Default is |
assign_model
will be modified to check if data are conformable
to specified model.
A list of model specifications:
num_slice
A vector counting the No. of measurement slices for each
level of measurement quality (e.g., MBS, MSS, MGS representing
Bronze-Standard Measurements - case-control,
Silver-Standard Measurements and Gold-Standard
Measurements - case-only);
nested
Local dependence specification for modeling bronze-standard
data. TRUE
for nested models (conditional dependence given disease class);
FALSE
for non-nested models (conditional independence given disease class).
One for each BrS slice.
regression
do_reg_Eti
TRUE
for doing etiology regression.
It means let the etiology fractions vary with explanatory variables.
FALSE
otherwise;
do_reg_FPR
A vector whose names represent the slices
of bronze-standard data. For each slice of BrS measurements,
TRUE
does false positive rate regression. It means the false
positive rates, estimatable from controls, can vary with
covariates; FALSE
otherwise.
is_discrete_predictor
A list of names "Eti", and
the names for every slice of bronze-standard data. TRUE
if all predictors are discrete; FALSE
otherwise.
cause_list <- c(LETTERS[1:6]) J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) data("data_nplcm_noreg") assign_model(model_options_no_reg,data_nplcm_noreg)
cause_list <- c(LETTERS[1:6]) J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) data("data_nplcm_noreg") assign_model(model_options_no_reg,data_nplcm_noreg)
baker
is designed for disease etiology studies from case-control data
with multiple sources of measurements with potential errors. If you are
interested in estimating the population etiology pie (a vector of fractions
that sum to one), and the probability of each cause for a particular
individual case, try baker
.
baker
implements hierarchical Bayesian models to infer disease etiology
for multivariate binary data. We created baker
to catalyze effective
communications between analysts and practicing clinicians that are vital to
the success of etiology studies. The baker
package offers
modules to
Import and tidy the PERCH data (the study that motivates the creation of this package),
Transform, explore the data,
Specify, automatically generate the model files, and fit the models (npLCM),
Store and visualize posterior summaries for communicating scientific findings, and
Check and compare the fitted models.
baker
has implemented models for dependent
measurements given disease status, regression analyses of etiology,
multiple imperfect measurements, different priors for true positive rates
among cases with differential measurement characteristics, and
multiple-pathogen etiology. Scientists in Pneumonia Etiology Research for
Child Health (PERCH) study usually refer to the etiology distribution
as "population etiology pie" and "individual etiology pie" for their
compositional nature, hence the name of the package (baking the pie).
No returned value; documentation purpose only.
https://github.com/zhenkewu/baker for the source code
and system/software requirements to use baker
for your data.
beta_parms_from_quantiles
produces prior Beta parameters for
the true positive rates (TPR)
beta_parms_from_quantiles( q, p = c(0.025, 0.975), precision = 0.001, derivative.epsilon = 0.001, start.with.normal.approx = TRUE, start = c(1, 1), plot = FALSE )
beta_parms_from_quantiles( q, p = c(0.025, 0.975), precision = 0.001, derivative.epsilon = 0.001, start.with.normal.approx = TRUE, start = c(1, 1), plot = FALSE )
q |
A vector of lower and upper bounds, in which Beta distribution
will have quantiles specified by |
p |
The lower and upper quantiles of the range one wants to specify. |
precision |
Approximation precisions. |
derivative.epsilon |
Precision of calculating derivative. |
start.with.normal.approx |
Default is |
start |
Starting values of beta parameters. |
plot |
Default is |
A list containing the selected Beta parameters a
, and b
.
Other elements of the list include some details about the computations involved
in finding a
and b
.
http://www.medicine.mcgill.ca/epidemiology/Joseph/PBelisle/BetaParmsFromQuantiles.html
beta_parms_from_quantiles(c(0.5,0.99))
beta_parms_from_quantiles(c(0.5,0.99))
Plot beta density
beta_plot(a, b)
beta_plot(a, b)
a |
The first parameter |
b |
The second parameter |
None
beta_plot(2,2)
beta_plot(2,2)
Useful when try to list all the binary patterns. One can group the binary sequences according to their equivalent decimal values.
bin2dec(binary_vector)
bin2dec(binary_vector)
binary_vector |
a binary number |
a decimal number
bin2dec(c(1,0,1))
bin2dec(c(1,0,1))
check existence and create folder if non-existent
check_dir_create(path)
check_dir_create(path)
path |
Folder path to check and create if not there. |
the same returned values for dir.create()
check_dir_create(tempdir())
check_dir_create(tempdir())
In the Actual PERCH data set, a study site may have multiple subsites.
clean_combine_subsites
combines all the study subjects from the same site.
clean_combine_subsites(raw_meas_dir, subsites_list, newsites_vec)
clean_combine_subsites(raw_meas_dir, subsites_list, newsites_vec)
raw_meas_dir |
The file path to the raw data file (.csv) |
subsites_list |
The list of subsite group names. Each group is a vector of subsites to be combined |
newsites_vec |
A vector of new site names. It has the same length as
|
A data frame with combined sites
clean_perch_data
transforms a raw data table (row for subjects, column
for variables - named as {pathogen name}_{specimen}{test}
for lab tests
or other covariates) into a list. It is designed for PERCH data format.
clean_perch_data(clean_options)
clean_perch_data(clean_options)
clean_options |
The list of options for cleaning PERCH data. Its elements are defined as follows:
. |
A List: list(Mobs,Y,X)
Mobs
A list of bronze- (MBS
), silver- (MSS
),
and gold-standard (MGS
, if available) measurements. See the formats
of these measurements in extract_data_raw()
.
Y
1 for case; 0 for control;
X
Data frame of covariates for cases and controls. The covariate
names are specified in X_extra
;
This function does not re-order pathogens that only have silver-standard data.
make_meas_object for wrapping information about a particular
type of measurement; extract_data_raw for reading raw data table
and organizing them into data_nplcm
format. Also see clean_combine_subsites
for combining subsites and parse_date_time for parsing date.
combine multiple data_nplcm (useful when simulating data from regression models)
combine_data_nplcm(data_nplcm_list)
combine_data_nplcm(data_nplcm_list)
data_nplcm_list |
a list of data_nplcm in |
a list with each element resulting from row binding of each
corresponding element in the input data_nplcm_list
.
Other data operation functions:
merge_lists()
,
subset_data_nplcm_by_index()
N=100 Y = rep(c(1,0),times=50) # simulate two cases and two controls. out_list <- vector("list",length=N) J = 3 # number of causes cause_list = c(LETTERS[1:J]) # cause list K = 2 # number of subclasses lambda = c(.8,.2) # subclass weights for control group eta = c(.9,.1) # subclass weights for case group for (i in 1:N){ #setup parameters for the present individual: set_parameter <- list( cause_list = cause_list, etiology = c(0.5,0.2,0.3), # only meaningful for cases pathogen_BrS = LETTERS[1:J], pathogen_SS = LETTERS[1:2], meas_nm = list(MBS = c("MBS1"),MSS=c("MSS1")), Lambda = lambda, # for BrS Eta = t(replicate(J,eta)), # case subclass weight for BrS PsiBS = cbind(c(0.15,0.3,0.35), c(0.25,0.2,0.15)), # FPR PsiSS = cbind(rep(0,J),rep(0,J)), ThetaBS = cbind(c(0.95,0.9,0.85), # TPR c(0.95,0.9,0.85)), ThetaSS = cbind(c(0.25,0.10), c(0.25,0.10)), Nd = 1, Nu = 1 ) simu_out <- simulate_nplcm(set_parameter) out <- simu_out$data_nplcm out_list[[i]] <- out } # extract cases and controls and combine all the data into one: data_nplcm_list <- lapply(1:N, function(s) subset_data_nplcm_by_index(out_list[[s]],2-Y[s])) data_nplcm_unordered <- combine_data_nplcm(data_nplcm_list)
N=100 Y = rep(c(1,0),times=50) # simulate two cases and two controls. out_list <- vector("list",length=N) J = 3 # number of causes cause_list = c(LETTERS[1:J]) # cause list K = 2 # number of subclasses lambda = c(.8,.2) # subclass weights for control group eta = c(.9,.1) # subclass weights for case group for (i in 1:N){ #setup parameters for the present individual: set_parameter <- list( cause_list = cause_list, etiology = c(0.5,0.2,0.3), # only meaningful for cases pathogen_BrS = LETTERS[1:J], pathogen_SS = LETTERS[1:2], meas_nm = list(MBS = c("MBS1"),MSS=c("MSS1")), Lambda = lambda, # for BrS Eta = t(replicate(J,eta)), # case subclass weight for BrS PsiBS = cbind(c(0.15,0.3,0.35), c(0.25,0.2,0.15)), # FPR PsiSS = cbind(rep(0,J),rep(0,J)), ThetaBS = cbind(c(0.95,0.9,0.85), # TPR c(0.95,0.9,0.85)), ThetaSS = cbind(c(0.25,0.10), c(0.25,0.10)), Nd = 1, Nu = 1 ) simu_out <- simulate_nplcm(set_parameter) out <- simu_out$data_nplcm out_list[[i]] <- out } # extract cases and controls and combine all the data into one: data_nplcm_list <- lapply(1:N, function(s) subset_data_nplcm_by_index(out_list[[s]],2-Y[s])) data_nplcm_unordered <- combine_data_nplcm(data_nplcm_list)
This only works for single-agent causes
compute_logOR_single_cause(set_parameter)
compute_logOR_single_cause(set_parameter)
set_parameter |
True model parameters in an npLCM specification:
|
a matrix of log odds ratio. See the example for a figure showing pairwise odds ratios for cases (upper right, solid lines) and controls (lower left, broken lines) as the first subclass weight increases from 0 to 1. Pairwise independence is represented by the dotted horizontal lines for reference.
K.true <- 2 # no. of latent subclasses in actual simulation. # If eta = c(1,0), effectively, it is K.true=1 J <- 5 # no. of pathogens. N <- 500 # no. of cases/controls. col_seq_cause <- c("#DB9D85","#A2B367","#47BEA2", "#70B3DA","#CD99D8")#colorspace::rainbow_hcl(5, start = 30, end = 300) subclass_mix_seq <- seq(0,1,by=0.05) res <- array(NA,c(J,J,length(subclass_mix_seq))) res_cond <- array(NA,c(J,J,length(subclass_mix_seq),J)) it <- layout(matrix(1:J^2,nrow=J,ncol=J,byrow=TRUE), heights = rep(3,J), widths = rep(3,J)) oldpar <- par(oma=c(8,10,8,3)); pch_seq_cause <- LETTERS[1:J] lty_seq_cause <- 1+(1:J) pch_pos_seq <- c(0.01); gap = 0.15 adj_seq <- c(0.15,0.5,0.85) # for roman numerals: cex1 <- 2 cex_label1 <- 1 cex2 <- 2 cex_label2 <- 2 cex_margin_marks <- 2 for (scn in c(1,2,3)){ for (iter in seq_along(subclass_mix_seq)){ curr_mix <- subclass_mix_seq[iter] lambda <- c(curr_mix,1-curr_mix) eta <- c(curr_mix,1-curr_mix) # if it is c(1,0),then it is conditional independence model, and # only the first column of parameters in PsiBS, ThetaBS matter! seed_start <- 20150923 # set fixed simulation sequence: set.seed(seed_start) if (scn == 3){ ThetaBS_withNA <- cbind(c(0.95,0.9,0.1,0.5,0.5), c(0.95,0.1,0.9,0.5,0.5)) PsiBS_withNA <- cbind(c(0.4,0.4,0.05,0.2,0.2), c(0.05,0.05,0.4,0.05,0.05)) } if (scn == 2){ ThetaBS_withNA <- cbind(c(0.95,0.5,0.5,0.5,0.5), c(0.95,0.5,0.5,0.5,0.5)) PsiBS_withNA <- cbind(c(0.4,0.4,0.05,0.2,0.2), c(0.05,0.05,0.4,0.05,0.05)) } if (scn == 1){ ThetaBS_withNA <- cbind(c(0.95,0.5,0.5,0.5,0.5), c(0.95,0.5,0.5,0.5,0.5)) PsiBS_withNA <- cbind(c(0.3,0.3,0.15,0.2,0.2), c(0.15,0.15,0.3,0.05,0.05)) } # the following paramter names are set using names in the 'baker' package: set_parameter0 <- list( cause_list = c(LETTERS[1:J]), etiology = c(0.5,0.2,0.15,0.1,0.05), #same length as cause_list #etiology = rep(0.2,J), #same length as cause_list pathogen_BrS = LETTERS[1:J], meas_nm = list(MBS = c("MBS1")), Lambda = lambda, #ctrl mix Eta = t(replicate(J,eta)), #case mix, row number equal to Jcause. PsiBS = PsiBS_withNA, ThetaBS = ThetaBS_withNA, Nu = N, # control size. Nd = N # case size. ) res[,,iter] <- round(compute_logOR_single_cause(set_parameter0),2) for (pick in 1:J){ set_parameter <- set_parameter0 set_parameter$ThetaBS <- set_parameter0$PsiBS set_parameter$ThetaBS[pick,] <- set_parameter0$ThetaBS[pick,] set_parameter$etiology <- rep(0,J); set_parameter$etiology[pick] <- 1 res_cond[,,iter,pick] <- round(compute_logOR_single_cause(set_parameter),2) } } ind <- sapply(c(0,0.5,1),function(x) which(subclass_mix_seq==x)) logOR_lim <- c(-2.15,2.15) col_seq <- c("dodgerblue2","orange") logOR_seq <- log(c(0.25,0.5,1,2,4)) pick_one <- 3 print(paste0("==Shading pairs of ",pch_seq_cause[pick_one]," and others.===")) for (j in 1:J){ for (l in 1:J){ par(mar=c(0,0,0,0)); if (j==J){ par(mar=c(0,0,0,0)) } if (l%%J==0){ par(mar=c(0,0,0,1)) } if (l%%J==1){ par(mar=c(0,1,0,0)) } if (!(j==l)){ plot(res[j,l,],type="l",xlab="",ylab="", ylim=logOR_lim, lwd=5, xaxt="n", yaxt="n", col=col_seq[1+(l>j)], #lty=c(2,1)[1+(l>j)], lty=1, bty="n" ) box(col="lightgray") abline(h=0,col="lightgray",lwd=3,lty=3) if (j<l){ matplot(res_cond[j,l,,],type="l",add=TRUE,pch=LETTERS[1:J],lwd=2,lty=2, col=col_seq_cause) } lab_ord <- c(j,l); if (j>l){lab_ord <- rev(lab_ord)} mtext(paste0("(",set_parameter$pathogen_BrS[lab_ord[1]],",", set_parameter$pathogen_BrS[lab_ord[2]],")"), side=3, adj=0.1,line=-2) if (l%%J==1){ axis(2,at = logOR_seq, labels = round(exp(logOR_seq),1), las=2,cex.axis=cex1) } if (l%%J==0){ axis(4,at = logOR_seq, labels = round(exp(logOR_seq),1), las=2,cex.axis=cex1) } if (j==J){ axis(1,at=seq_along(subclass_mix_seq)[ind], labels=rep("",length(ind)),cex.axis = cex1,las=1) axis(1,at=seq_along(subclass_mix_seq)[ind]+c(1,rep(0,length(ind)-2),-1), labels=subclass_mix_seq[ind],cex.axis = cex1,las=1,tick=FALSE) } if (j==1){ axis(3,at=seq_along(subclass_mix_seq)[ind], labels=rep("",length(ind)),cex.axis = cex1,las=1) axis(3,at=seq_along(subclass_mix_seq)[ind]+c(1,rep(0,length(ind)-2),-1), labels=subclass_mix_seq[ind],cex.axis = cex1,las=1,tick=FALSE) } if (j==5 & l==1){ mtext(expression(atop("Odds Ratio","(log-scale)")), side = 2, line = 4, cex=cex_label1, las=2) } if (j==5){ mtext(expression(lambda[o]),side=1,line=4,cex=cex_label1) } if ((j<l) && (l==pick_one | j==pick_one )){ # add shading cells for oen picked pathogen among cases: color <- rgb(190, 190, 190, alpha=80, maxColorValue=255) rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], density = 100, col = color) matplot(res_cond[j,l,,],type="l",add=TRUE,lwd=2,col=col_seq_cause,lty=lty_seq_cause) for (ell in 1:J){ where_add_letter <- quantile(seq_along(subclass_mix_seq),pch_pos_seq+gap*ell) points(where_add_letter, res_cond[j,l,where_add_letter,ell], pch=pch_seq_cause[ell]) } mtext(paste0("(",set_parameter$pathogen_BrS[lab_ord[1]],",", set_parameter$pathogen_BrS[lab_ord[2]],")"), side=3, adj=0.1,line=-2) } }else{ plot(1, type="n", axes=FALSE, xlab="", ylab="", bty="n", xlim=c(0,1),ylim=c(0,1)) if (j==3){ text(labels=expression(CASES%up%""),x=.7, y=0.55,srt=-49,col=col_seq[2],cex=1.8,adj=0.5,font=4) text(labels=expression(CONTROLS%down%""),x=.42, y=0.38,srt=-49,col=col_seq[1],cex=1.8,adj=0.5,font=4) } if (j!=1 & j!=J){ dg <- par("usr") segments(dg[1],dg[4],dg[2],dg[3], col='lightgray',lwd=3) } if (j==J){ legend("top",LETTERS[1:J],lty=2,col=col_seq_cause,cex = 1.5,lwd=2, bty="n",horiz=FALSE) } } } } } par(oldpar)
K.true <- 2 # no. of latent subclasses in actual simulation. # If eta = c(1,0), effectively, it is K.true=1 J <- 5 # no. of pathogens. N <- 500 # no. of cases/controls. col_seq_cause <- c("#DB9D85","#A2B367","#47BEA2", "#70B3DA","#CD99D8")#colorspace::rainbow_hcl(5, start = 30, end = 300) subclass_mix_seq <- seq(0,1,by=0.05) res <- array(NA,c(J,J,length(subclass_mix_seq))) res_cond <- array(NA,c(J,J,length(subclass_mix_seq),J)) it <- layout(matrix(1:J^2,nrow=J,ncol=J,byrow=TRUE), heights = rep(3,J), widths = rep(3,J)) oldpar <- par(oma=c(8,10,8,3)); pch_seq_cause <- LETTERS[1:J] lty_seq_cause <- 1+(1:J) pch_pos_seq <- c(0.01); gap = 0.15 adj_seq <- c(0.15,0.5,0.85) # for roman numerals: cex1 <- 2 cex_label1 <- 1 cex2 <- 2 cex_label2 <- 2 cex_margin_marks <- 2 for (scn in c(1,2,3)){ for (iter in seq_along(subclass_mix_seq)){ curr_mix <- subclass_mix_seq[iter] lambda <- c(curr_mix,1-curr_mix) eta <- c(curr_mix,1-curr_mix) # if it is c(1,0),then it is conditional independence model, and # only the first column of parameters in PsiBS, ThetaBS matter! seed_start <- 20150923 # set fixed simulation sequence: set.seed(seed_start) if (scn == 3){ ThetaBS_withNA <- cbind(c(0.95,0.9,0.1,0.5,0.5), c(0.95,0.1,0.9,0.5,0.5)) PsiBS_withNA <- cbind(c(0.4,0.4,0.05,0.2,0.2), c(0.05,0.05,0.4,0.05,0.05)) } if (scn == 2){ ThetaBS_withNA <- cbind(c(0.95,0.5,0.5,0.5,0.5), c(0.95,0.5,0.5,0.5,0.5)) PsiBS_withNA <- cbind(c(0.4,0.4,0.05,0.2,0.2), c(0.05,0.05,0.4,0.05,0.05)) } if (scn == 1){ ThetaBS_withNA <- cbind(c(0.95,0.5,0.5,0.5,0.5), c(0.95,0.5,0.5,0.5,0.5)) PsiBS_withNA <- cbind(c(0.3,0.3,0.15,0.2,0.2), c(0.15,0.15,0.3,0.05,0.05)) } # the following paramter names are set using names in the 'baker' package: set_parameter0 <- list( cause_list = c(LETTERS[1:J]), etiology = c(0.5,0.2,0.15,0.1,0.05), #same length as cause_list #etiology = rep(0.2,J), #same length as cause_list pathogen_BrS = LETTERS[1:J], meas_nm = list(MBS = c("MBS1")), Lambda = lambda, #ctrl mix Eta = t(replicate(J,eta)), #case mix, row number equal to Jcause. PsiBS = PsiBS_withNA, ThetaBS = ThetaBS_withNA, Nu = N, # control size. Nd = N # case size. ) res[,,iter] <- round(compute_logOR_single_cause(set_parameter0),2) for (pick in 1:J){ set_parameter <- set_parameter0 set_parameter$ThetaBS <- set_parameter0$PsiBS set_parameter$ThetaBS[pick,] <- set_parameter0$ThetaBS[pick,] set_parameter$etiology <- rep(0,J); set_parameter$etiology[pick] <- 1 res_cond[,,iter,pick] <- round(compute_logOR_single_cause(set_parameter),2) } } ind <- sapply(c(0,0.5,1),function(x) which(subclass_mix_seq==x)) logOR_lim <- c(-2.15,2.15) col_seq <- c("dodgerblue2","orange") logOR_seq <- log(c(0.25,0.5,1,2,4)) pick_one <- 3 print(paste0("==Shading pairs of ",pch_seq_cause[pick_one]," and others.===")) for (j in 1:J){ for (l in 1:J){ par(mar=c(0,0,0,0)); if (j==J){ par(mar=c(0,0,0,0)) } if (l%%J==0){ par(mar=c(0,0,0,1)) } if (l%%J==1){ par(mar=c(0,1,0,0)) } if (!(j==l)){ plot(res[j,l,],type="l",xlab="",ylab="", ylim=logOR_lim, lwd=5, xaxt="n", yaxt="n", col=col_seq[1+(l>j)], #lty=c(2,1)[1+(l>j)], lty=1, bty="n" ) box(col="lightgray") abline(h=0,col="lightgray",lwd=3,lty=3) if (j<l){ matplot(res_cond[j,l,,],type="l",add=TRUE,pch=LETTERS[1:J],lwd=2,lty=2, col=col_seq_cause) } lab_ord <- c(j,l); if (j>l){lab_ord <- rev(lab_ord)} mtext(paste0("(",set_parameter$pathogen_BrS[lab_ord[1]],",", set_parameter$pathogen_BrS[lab_ord[2]],")"), side=3, adj=0.1,line=-2) if (l%%J==1){ axis(2,at = logOR_seq, labels = round(exp(logOR_seq),1), las=2,cex.axis=cex1) } if (l%%J==0){ axis(4,at = logOR_seq, labels = round(exp(logOR_seq),1), las=2,cex.axis=cex1) } if (j==J){ axis(1,at=seq_along(subclass_mix_seq)[ind], labels=rep("",length(ind)),cex.axis = cex1,las=1) axis(1,at=seq_along(subclass_mix_seq)[ind]+c(1,rep(0,length(ind)-2),-1), labels=subclass_mix_seq[ind],cex.axis = cex1,las=1,tick=FALSE) } if (j==1){ axis(3,at=seq_along(subclass_mix_seq)[ind], labels=rep("",length(ind)),cex.axis = cex1,las=1) axis(3,at=seq_along(subclass_mix_seq)[ind]+c(1,rep(0,length(ind)-2),-1), labels=subclass_mix_seq[ind],cex.axis = cex1,las=1,tick=FALSE) } if (j==5 & l==1){ mtext(expression(atop("Odds Ratio","(log-scale)")), side = 2, line = 4, cex=cex_label1, las=2) } if (j==5){ mtext(expression(lambda[o]),side=1,line=4,cex=cex_label1) } if ((j<l) && (l==pick_one | j==pick_one )){ # add shading cells for oen picked pathogen among cases: color <- rgb(190, 190, 190, alpha=80, maxColorValue=255) rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], density = 100, col = color) matplot(res_cond[j,l,,],type="l",add=TRUE,lwd=2,col=col_seq_cause,lty=lty_seq_cause) for (ell in 1:J){ where_add_letter <- quantile(seq_along(subclass_mix_seq),pch_pos_seq+gap*ell) points(where_add_letter, res_cond[j,l,where_add_letter,ell], pch=pch_seq_cause[ell]) } mtext(paste0("(",set_parameter$pathogen_BrS[lab_ord[1]],",", set_parameter$pathogen_BrS[lab_ord[2]],")"), side=3, adj=0.1,line=-2) } }else{ plot(1, type="n", axes=FALSE, xlab="", ylab="", bty="n", xlim=c(0,1),ylim=c(0,1)) if (j==3){ text(labels=expression(CASES%up%""),x=.7, y=0.55,srt=-49,col=col_seq[2],cex=1.8,adj=0.5,font=4) text(labels=expression(CONTROLS%down%""),x=.42, y=0.38,srt=-49,col=col_seq[1],cex=1.8,adj=0.5,font=4) } if (j!=1 & j!=J){ dg <- par("usr") segments(dg[1],dg[4],dg[2],dg[3], col='lightgray',lwd=3) } if (j==J){ legend("top",LETTERS[1:J],lty=2,col=col_seq_cause,cex = 1.5,lwd=2, bty="n",horiz=FALSE) } } } } } par(oldpar)
Jcause
classes for each person (people may have different weights.)The array version of this function (compute_marg_PR_nested_reg_array) is used in plot_etiology_regression
compute_marg_PR_nested_reg(ThetaBS, PsiBS, pEti_mat, subwt_mat, case, template)
compute_marg_PR_nested_reg(ThetaBS, PsiBS, pEti_mat, subwt_mat, case, template)
ThetaBS |
True positive rates for |
PsiBS |
False positive rates; dimension same as above |
pEti_mat |
a matrix of etiology pies for |
subwt_mat |
a matrix of subclass weights for cases and controls. |
case |
a N-vector of |
template |
a binary matrix with |
a matrix of values between 0
and 1
(need not to have row sums of ones);
of dimension (number of subjects, dimension of the bronze-standard measurement slice).
Jcause
classes for each person (people may have different weights.)This is an array-version of compute_marg_PR_nested_reg. This is used in plot_etiology_regression
compute_marg_PR_nested_reg_array( ThetaBS_array, PsiBS_array, pEti_mat_array, subwt_mat_array, case, template )
compute_marg_PR_nested_reg_array( ThetaBS_array, PsiBS_array, pEti_mat_array, subwt_mat_array, case, template )
ThetaBS_array |
An array of: True positive rates for JBrS measures (rows) among K subclasses (columns) |
PsiBS_array |
An array of: False positive rates; dimension same as above |
pEti_mat_array |
An array of: a matrix of etiology pies for N subjects (rows) and Jcause causes (columns) rows sum to ones. |
subwt_mat_array |
An array of: a matrix of subclass weights for cases and controls. N by K. Rows sum to ones. |
case |
a N-vector of 1s (cases) and 0s (controls) |
template |
a binary matrix with Jcause+1 rows (Jcause classes of cases and 1 class of controls) and JBrS columns for the Bronze-standard measurement (say, pick one type/slice). The ones in each row indicate the measurements that will show up more frequently in cases given the cause. |
An array of: a matrix of values between 0 and 1 (need not to have row sums of ones); of dimension (number of subjects, dimension of the bronze-standard measurement slice).
create_bugs_regressor_Eti
creates linear product of coefficients
and a row of design matrix used in regression
create_bugs_regressor_Eti( n, dm_nm = "dm_Eti", b_nm = "betaEti", ind_nm = "j", sub_ind_nm = "k" )
create_bugs_regressor_Eti( n, dm_nm = "dm_Eti", b_nm = "betaEti", ind_nm = "j", sub_ind_nm = "k" )
n |
the length of coefficients |
dm_nm |
name of design matrix; default |
b_nm |
name of the coefficients; default |
ind_nm |
name of the coefficient iterator; default |
sub_ind_nm |
name of the subject iterator; default |
a character string with linear product form
create_bugs_regressor_FPR
creates linear product of coefficients
and a row of design matrix used in regression
create_bugs_regressor_FPR( n, dm_nm = "dm_FPR", b_nm = "b", ind_nm = "j", sub_ind_nm = "k" )
create_bugs_regressor_FPR( n, dm_nm = "dm_FPR", b_nm = "b", ind_nm = "j", sub_ind_nm = "k" )
n |
the length of coefficients |
dm_nm |
name of design matrix; default |
b_nm |
name of the coefficients; default |
ind_nm |
name of the coefficient iterator; default |
sub_ind_nm |
name of the subject iterator; default |
a character string with linear product form
nplcm()
without regressionData set for illustrating regression functionalities
data("data_nplcm_noreg")
data("data_nplcm_noreg")
A list containing three items
BrS level measurements: N = 600 (half cases and half controls); one slice of BrS measurements (6 dimensional, A-F); one slice of SS measurements (2 dimensional, A and B)
case-control status
No returned value; just loading data into the working space.
nplcm()
with regressionData set for illustrating regression functionalities
data("data_nplcm_reg_nest")
data("data_nplcm_reg_nest")
A list containing three items
BrS level measurements: N = 1,200 (half cases and half controls); one slice of BrS measurements (6 dimensional, A-F); one slice of SS measurements (2 dimensional, A and B)
case-control status
matrix of covariates (N by 4); columns: SITE (1 and 2, each with 600 subjects), DATE (index from 1:300), std_date (standardized DATE), ENRLDATE (actual dates)
No returned value; just loading data into the working space.
delete_start_with
is used for clean the column names in raw data.
For example, R adds "X" at the start of variable names. This function deletes
"X_"s from the column names. This can happen if the raw data have column
names such as "_CASE_ABX
". Check clean_perch_data()
for
its actual usage.
delete_start_with(s, vec)
delete_start_with(s, vec)
s |
the pattern (a single string) to be deleted from the start. |
vec |
a vector of strings with unwanted starting strings (specified by |
string(s) with deleted patterns from the start.
delete_start_with("X_",c("X_hello")) delete_start_with("X_",c("X_hello","hello2")) delete_start_with("X_",c("X_hello","hello2","X_hello3"))
delete_start_with("X_",c("X_hello")) delete_start_with("X_",c("X_hello","hello2")) delete_start_with("X_",c("X_hello","hello2","X_hello3"))
dm_Rdate_Eti
creates design matrices for etiology regressions.
dm_Rdate_Eti(Rdate, Y, num_knots_Eti, basis_Eti = "ncs")
dm_Rdate_Eti(Rdate, Y, num_knots_Eti, basis_Eti = "ncs")
Rdate |
a vector of dates of R format |
Y |
binary case/control status; 1 for case; 0 for controls |
num_knots_Eti |
number of knots for etiology regression |
basis_Eti |
the type of basis functions to use for etiology regression. It can be "ncs" (natural cubic splines) or "tprs" (thin-plate regression splines). Default is "ncs". "tprs" will be implemented later. |
It is used in model_options$likeihood$Eti_formula
. For example, one can specify
it as: ~ AGECAT+HIV+dm_Rdate_Eti(ENRLDATE,Y,5)
to call an etiology regression with intercept, main effects for 'AGECAT' and 'HIV', and
natural cubic spline bases for 'ENRLDATE' using 5 knots defined as 5 equal-probability-spaced
sample quantiles.
Design matrix for etiology regression:
Z_Eti
transformed design matrix for etiology regression
dm_Rdate_FPR
creates design matrices for false positive rate regressions;
can also be used to standardize dates.
dm_Rdate_FPR(Rdate, Y, effect = "fixed", num_knots_FPR = NULL)
dm_Rdate_FPR(Rdate, Y, effect = "fixed", num_knots_FPR = NULL)
Rdate |
a vector of dates of R format |
Y |
binary case/control status; 1 for case; 0 for controls |
effect |
The design matrix for "random" or "fixed" effect; Default
is "fixed". When specified as "fixed", it produces standardized R-format dates
using control's mean and standard deviation; When specified as "random", it produces
|
num_knots_FPR |
number of knots for FPR regression; default is |
Design matrix for FPR regression:
Z_FPR_ctrl
transformed design matrix for FPR regression for controls
Z_FPR_case
transformed design matrix for borrowing FPR
regression from controls to cases. It is obtained using control-standardization,
and square-root the following matrix (]) with (
,
) element being
.
expit function
expit(x)
expit(x)
x |
A real number |
a Probability between 0 and 1
expit(-0.1)
expit(-0.1)
extract_data_raw
imports and converts the raw data to analyzable formatImport Raw PERCH Data
extract_data_raw
imports and converts the raw data to analyzable format
extract_data_raw( dat_prepared, strat_nm, strat_val, meas_object, extra_covariates = NULL )
extract_data_raw( dat_prepared, strat_nm, strat_val, meas_object, extra_covariates = NULL )
dat_prepared |
The data set prepared in |
strat_nm |
The vector of covariate names to separately extract data.
For example, in PERCH data cleaning, |
strat_val |
The list of covariate values to stratify data.
Each element corresponds to elements in |
meas_object |
A list of bronze-standard or silver-standard measurement
objects made by function |
extra_covariates |
The vector of covariate name for regression purposes. The default is NULL, which means not reading in any covariate. |
A list of data.
A list of Bronze-Standard (BrS) measurements.
The names of the list take the form of specimen
_test
.
Each element of the list is a data frame. The rows of the data frame
are for subjects; the columns are for measured pathogens.
A list of Silver-Standard (SS) measurements.
The formats are the same as MBS
above.
A list of Gold-Standard (GS) measurements.
It equals NULL
if no GS data exist.
A data frame with columns specified by extra_covariates
.
Other raw data importing functions:
read_meas_object()
Obtain coverage status from a result folder
get_coverage(DIR_NPLCM, truth)
get_coverage(DIR_NPLCM, truth)
DIR_NPLCM |
Path to where Bayesian results are stored |
truth |
True etiologic fraction vector (must sum to 1) used to generate data. |
A logic vector of length as truth
. 1 for covered; 0 for not.
Obtain direct bias that measure the discrepancy of a posterior distribution of pie and a true pie.
get_direct_bias(DIR_list, truth = NULL, silent = FALSE)
get_direct_bias(DIR_list, truth = NULL, silent = FALSE)
DIR_list |
The list of where Bayesian results are stored |
truth |
True etiologic fraction vector (must sum to 1) used to generate data;
Default is |
silent |
Default is FALSE. To suppress printing messages, set to TRUE. |
a list of length two. diff
is the direct differences;
prb
is the percent relative bias.
get fitted mean for nested model with subclass mixing weights that are the same among cases
get_fitted_mean_nested( slice, res_nplcm, model_options, data_nplcm, clean_options )
get_fitted_mean_nested( slice, res_nplcm, model_options, data_nplcm, clean_options )
slice |
the slice of BrS data that are modeled |
res_nplcm |
matrix of MCMC samples |
model_options |
see |
data_nplcm |
see |
clean_options |
a matrix of no. of rows equal to retained MCMC samples, no. of columns equal to the no. of measurement dimensions within a slice.
get model fitted mean for conditional independence model
get_fitted_mean_no_nested( slice, res_nplcm, model_options, data_nplcm, clean_options )
get_fitted_mean_no_nested( slice, res_nplcm, model_options, data_nplcm, clean_options )
slice |
the slice of BrS data that are modeled |
res_nplcm |
matrix of MCMC samples |
model_options |
see |
data_nplcm |
see |
clean_options |
a list with model fitted means
get individual data
get_individual_data(i, data_nplcm)
get_individual_data(i, data_nplcm)
i |
index of individual as appeared in |
data_nplcm |
the data for nplcm; see |
a list of the same structure as data_nplcm
; just with one row of values
data(data_nplcm_noreg) get_individual_data(2,data_nplcm_noreg)
data(data_nplcm_noreg) get_individual_data(2,data_nplcm_noreg)
must set individual.pred = TRUE
in MCMC options (see the example of this
function)
get_individual_prediction(x)
get_individual_prediction(x)
x |
an |
a matrix of individual predictions; rows for cases, columns for causes
specified in model_options$likelihood$cause_list
; See nplcm()
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = TRUE, # <- must set to TRUE! ppd = FALSE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") fitted_nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg) image(get_individual_prediction(fitted_nplcm_noreg))
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = TRUE, # <- must set to TRUE! ppd = FALSE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") fitted_nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg) image(get_individual_prediction(fitted_nplcm_noreg))
get index of latent status
get_latent_seq(cause_list, ord, select_latent = NULL, exact = TRUE)
get_latent_seq(cause_list, ord, select_latent = NULL, exact = TRUE)
cause_list |
see mode_options in |
ord |
order of cause_list according to posterior mean |
select_latent |
Default is NULL |
exact |
Default is TRUE |
a vector of indices
get marginal TPR and FPR for nested model
get_marginal_rates_nested(slice, res_nplcm, model_options, data_nplcm)
get_marginal_rates_nested(slice, res_nplcm, model_options, data_nplcm)
slice |
the slice of BrS data that are modeled |
res_nplcm |
matrix of MCMC samples |
model_options |
see |
data_nplcm |
see |
a matrix of no. of rows equal to retained MCMC samples, no. of columns equal to the no. of measurement dimensions within a slice.
get marginal TPR and FPR for no nested model
get_marginal_rates_no_nested(slice, res_nplcm, model_options, data_nplcm)
get_marginal_rates_no_nested(slice, res_nplcm, model_options, data_nplcm)
slice |
the slice of BrS data that are modeled |
res_nplcm |
matrix of MCMC samples |
model_options |
see |
data_nplcm |
see |
a matrix of no. of rows equal to retained MCMC samples, no. of columns equal to the no. of measurement dimensions within a slice.
The result is equivalent to Euclidean-type calculation after the compositional vector (e.g., etiologic fraction) is centered-log-ratio (CLRB) transformed. For simulation only.
get_metric(DIR_NPLCM, truth)
get_metric(DIR_NPLCM, truth)
DIR_NPLCM |
File path where Bayesian results are stored |
truth |
True etiologic fraction vector (must sum to 1) used to generate data |
a vector of (Integrated Squared Aitchison Distance (ISAD), bias-squared, variance, truth)
get etiology samples by names (no regression)
get_pEti_samp(res_nplcm, model_options)
get_pEti_samp(res_nplcm, model_options)
res_nplcm |
result from model fits |
model_options |
model specification |
A list:
pEti_mat
: a matrix of posterior samples (iteration by cause); overall etiology
latent_nm
: a vector of character strings representing the names of the causes
get the plotting positions (numeric) for the fitted means; 3 positions for each cell
get_plot_num(e, height)
get_plot_num(e, height)
e |
Integer index from 1 to length(cause_list) |
height |
the total number of causes |
a triple with numerical plotting positions
get a list of measurement index where to look for data
get_plot_pos(template)
get_plot_pos(template)
template |
See |
a list of index vectors
Obtain posterior standard deviation from a result folder
get_postsd(DIR_NPLCM)
get_postsd(DIR_NPLCM)
DIR_NPLCM |
Path to where Bayesian results are stored |
a vector of positive numbers
get top patterns from a slice of bronze-standard measurement
get_top_pattern(BrS_dat, Y, case_status, n_pat, exclude_missing = TRUE)
get_top_pattern(BrS_dat, Y, case_status, n_pat, exclude_missing = TRUE)
BrS_dat |
bronze-standard data, which is usually |
Y |
A vector of case/control status: 1 for case; 0 for control |
case_status |
1 for case; 0 for controls |
n_pat |
the number of top patterns one wants to show |
exclude_missing |
DEFAULT is TRUE for excluding any individual with missing measurements. |
a list of results: obs_pat
- observed rates;
pattern_names
; exist_other
- if
actual no. of patterns is larger than n_pat
; N
- No. of individuals
with Y = case_status
.
Other exploratory data analysis functions:
plot_logORmat()
,
show_individual()
,
summarize_BrS()
,
summarize_SS()
,
visualize_season()
data(data_nplcm_noreg) get_top_pattern(data_nplcm_noreg$Mobs$MBS[[1]],data_nplcm_noreg$Y,1,5,FALSE) data(data_nplcm_noreg) get_top_pattern(data_nplcm_noreg$Mobs$MBS$MBS1,data_nplcm_noreg$Y,case_status=1,n_pat=5)
data(data_nplcm_noreg) get_top_pattern(data_nplcm_noreg$Mobs$MBS[[1]],data_nplcm_noreg$Y,1,5,FALSE) data(data_nplcm_noreg) get_top_pattern(data_nplcm_noreg$Mobs$MBS$MBS1,data_nplcm_noreg$Y,case_status=1,n_pat=5)
Shannon entropy for multivariate discrete data
H(px)
H(px)
px |
a vector of positive numbers sum to 1 |
a non-negative number
H(c(0.5,0.3,0.2))
H(c(0.5,0.3,0.2))
s_date_FPR()
test if a formula has terms not created by [s_date_Eti() or s_date_FPR()
has_non_basis(form)
has_non_basis(form)
form |
a formula |
logical TRUE
(if having terms not created by [s_date_Eti() or s_date_FPR()
);
FALSE
otherwise.
form1 <- as.formula(~ -1+s_date_FPR(DATE,Y,basis = "ps",10) + as.factor(SITE)) form2 <- as.formula(~ -1+s_date_FPR(DATE,Y,basis = "ps",10)) form3 <- as.formula(~ s_date_FPR(DATE,Y,basis = "ps",10)) has_non_basis(form1) has_non_basis(form2) has_non_basis(form3)
form1 <- as.formula(~ -1+s_date_FPR(DATE,Y,basis = "ps",10) + as.factor(SITE)) form2 <- as.formula(~ -1+s_date_FPR(DATE,Y,basis = "ps",10)) form3 <- as.formula(~ s_date_FPR(DATE,Y,basis = "ps",10)) has_non_basis(form1) has_non_basis(form2) has_non_basis(form3)
Reverse to symb2I()
I2symb(binary_code, pathogen_list)
I2symb(binary_code, pathogen_list)
binary_code |
Binary indicators for pathogens |
pathogen_list |
The complete list of pathogen names |
The name of pathogen or pathogen combination indicated by "code"
I2symb("001",c("A","B","C")) I2symb("000",c("A","B","C"))
I2symb("001",c("A","B","C")) I2symb("000",c("A","B","C"))
Convert a matrix of binary indicators to categorical variables
Imat2cat(binary_mat, cause_list, pathogen_list)
Imat2cat(binary_mat, cause_list, pathogen_list)
binary_mat |
The matrix of binary indicators. Rows for subjects, columns for pathogens in the |
cause_list |
The list of causes |
pathogen_list |
The complete list of pathogen names |
A vector of categorical variables. Its length equals the length of "allowed.list"
Imat2cat(rbind(diag(3),c(1,1,0),c(0,0,0)),c("A","B","C","A+B","NoA"),c("A","B","C"))
Imat2cat(rbind(diag(3),c(1,1,0),c(0,0,0)),c("A","B","C","A+B","NoA"),c("A","B","C"))
JAGS
)Initialize individual latent status (for JAGS
)
init_latent_jags_multipleSS( MSS_list, cause_list, patho = unlist(lapply(MSS_list, colnames)) )
init_latent_jags_multipleSS( MSS_list, cause_list, patho = unlist(lapply(MSS_list, colnames)) )
MSS_list |
A list of silver-standard measurement data, possibly with more than one
slices; see |
cause_list |
See |
patho |
A vector of measured pathogen name for |
In JAGS
3.4.0, if an initial value contradicts the probabilistic specification, e.g.
MSS_1[i,j] ~ dbern(mu_ss_1[i,j])
, where MSS_1[i,j]=1
but mu_ss_1[i,j]=0
,
then JAGS
cannot understand it. In PERCH application, this is most likely used when the specificity of the
silver-standard data is 1
. Note: this is not a problem in WinBUGS
.
a list of numbers, indicating categories of individual latent causes.
insert distribution for latent status code chunk into .bug file
insert_bugfile_chunk_noreg_etiology(ppd = NULL)
insert_bugfile_chunk_noreg_etiology(ppd = NULL)
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
a long character string to be inserted into .bug model file as distribution specification for latent status
Insert measurement likelihood (without regression) code chunks into .bug model file
insert_bugfile_chunk_noreg_meas( k_subclass, Mobs, prior, cause_list, use_measurements = "BrS", ppd = NULL, use_jags = FALSE )
insert_bugfile_chunk_noreg_meas( k_subclass, Mobs, prior, cause_list, use_measurements = "BrS", ppd = NULL, use_jags = FALSE )
k_subclass |
the number of subclasses for the slices that require conditional dependence modeling (only applicable to BrS data); its length is of the same value as the number of BrS slices. |
Mobs |
measurement data in the form of |
prior |
prior specification from |
cause_list |
a list of latent status names (crucial for building templates;
see |
use_measurements |
"BrS", or "SS" |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
use_jags |
Default is FALSE; set to TRUE if want to use JAGS for model fitting. |
a long character string to be inserted into .bug model file as measurement likelihood
It is used in write_model_NoReg for constructing a .bug file along with specification of latent status distribution (insert_bugfile_chunk_noreg_etiology)
insert etiology regression for latent status code chunk into .bug file; discrete predictors
insert_bugfile_chunk_reg_discrete_predictor_etiology(Jcause, ppd = NULL)
insert_bugfile_chunk_reg_discrete_predictor_etiology(Jcause, ppd = NULL)
Jcause |
The number of distinct causes, i.e., categories of latent health
status; equals |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
a long character string to be inserted into .bug model file as distribution specification for latent status
Insert measurement likelihood (with regression; discrete) code chunks into .bug model file
insert_bugfile_chunk_reg_discrete_predictor_nonest_meas( Mobs, prior, cause_list, use_measurements = "BrS", ppd = NULL, use_jags = FALSE )
insert_bugfile_chunk_reg_discrete_predictor_nonest_meas( Mobs, prior, cause_list, use_measurements = "BrS", ppd = NULL, use_jags = FALSE )
Mobs |
Measurement data in the form of |
prior |
Prior specification from |
cause_list |
A list of latent status names (crucial for building templates;
see |
use_measurements |
"BrS", or "SS" |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
use_jags |
Default is FALSE; set to TRUE if want to use JAGS for model fitting. |
A long character string to be inserted into .bug model file as measurement likelihood
It is used in write_model_Reg_NoNest for constructing a .bug file along with specification of latent status regression (insert_bugfile_chunk_reg_etiology)
insert etiology regression for latent status code chunk into .bug file
insert_bugfile_chunk_reg_etiology(Eti_formula, Jcause, ppd = NULL)
insert_bugfile_chunk_reg_etiology(Eti_formula, Jcause, ppd = NULL)
Eti_formula |
Etiology regression formula; Check |
Jcause |
The number of distinct causes, i.e., categories of latent health
status; equals |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
a long character string to be inserted into .bug model file as distribution specification for latent status
Insert measurement likelihood (nested model+regression) code chunks into .bug model file
insert_bugfile_chunk_reg_nest_meas( Mobs, prior, cause_list, FPR_formula, use_measurements = "BrS", ppd = NULL, use_jags = FALSE )
insert_bugfile_chunk_reg_nest_meas( Mobs, prior, cause_list, FPR_formula, use_measurements = "BrS", ppd = NULL, use_jags = FALSE )
Mobs |
Measurement data in the form of |
prior |
Prior specification from |
cause_list |
A list of latent status names (crucial for building templates;
see |
FPR_formula |
A list of FPR regression formula; check |
use_measurements |
"BrS", or "SS" |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
use_jags |
Default is FALSE; set to TRUE if want to use JAGS for model fitting. |
A long character string to be inserted into .bug model file as measurement likelihood
Called by write_model_Reg_NoNest for constructing a .bug
file.
This is usually called along with specification of latent status regression
(insert_bugfile_chunk_reg_etiology).
Insert measurement likelihood (with regression) code chunks into .bug model file
insert_bugfile_chunk_reg_nonest_meas( Mobs, prior, cause_list, FPR_formula, use_measurements = "BrS", ppd = NULL, use_jags = FALSE )
insert_bugfile_chunk_reg_nonest_meas( Mobs, prior, cause_list, FPR_formula, use_measurements = "BrS", ppd = NULL, use_jags = FALSE )
Mobs |
Measurement data in the form of |
prior |
Prior specification from |
cause_list |
A list of latent status names (crucial for building templates;
see |
FPR_formula |
A list of FPR regression formula; check |
use_measurements |
"BrS", or "SS" |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
use_jags |
Default is FALSE; set to TRUE if want to use JAGS for model fitting. |
A long character string to be inserted into .bug model file as measurement likelihood
It is used in write_model_Reg_NoNest for constructing a .bug file along with specification of latent status regression (insert_bugfile_chunk_reg_etiology)
is_discrete
checks if the specified covariates could be regarded as discrete
variables.
is_discrete(X, X_reg)
is_discrete(X, X_reg)
X |
A data frame of covariates |
X_reg |
The vector of covariates that will stratify the analyses. These
variables have to be categorical. Or a formula (can be tested by |
Note that this function should be used with caution. It used
as an ad hoc criterion.
It is not the same as is.discrete()
in plyr
TRUE
for all being discrete; FALSE
otherwise.
outputs logical values for a formula; to identify intercept-only formula.
is_intercept_only(form)
is_intercept_only(form)
form |
Regression formula |
TRUE
for intercept-only; FALSE
otherwise
See if a result folder is obtained by JAGS
is_jags_folder(DIR_NPLCM)
is_jags_folder(DIR_NPLCM)
DIR_NPLCM |
directory to the folder with results. "mcmc_options.txt" must be in the folder. |
TRUE for from JAGS; FALSE otherwise.
is_jags_folder(tempdir()) # just an illustration.
is_jags_folder(tempdir()) # just an illustration.
check if a list has elements all of length one
is_length_all_one(x)
is_length_all_one(x)
x |
a list |
TRUE or FALSE
l = list(a = 5, b = 1:2) is_length_all_one(l) # FALSE l = list(a = 5, b = 1) is_length_all_one(l) # TRUE
l = list(a = 5, b = 1:2) is_length_all_one(l) # FALSE l = list(a = 5, b = 1) is_length_all_one(l) # TRUE
Test for 'try-error' class
is.error(x)
is.error(x)
x |
An object to be test if it is "try-error" |
Logical. TRUE
for "try-error"; FALSE
otherwise
http://adv-r.had.co.nz/Exceptions-Debugging.html
JAGS
from RThe jags function takes data and starting values as input. It automatically writes a jags script, calls the model, and saves the simulations for easy access in R. Check the R2jags::jags2 for details about the argument.
jags2_baker( data, inits, parameters.to.save, model.file = "model.bug", n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), n.thin = max(1, floor((n.iter - n.burnin)/1000)), DIC = TRUE, jags.path = "", working.directory = NULL, clearWD = TRUE, refresh = n.iter/50 )
jags2_baker( data, inits, parameters.to.save, model.file = "model.bug", n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), n.thin = max(1, floor((n.iter - n.burnin)/1000)), DIC = TRUE, jags.path = "", working.directory = NULL, clearWD = TRUE, refresh = n.iter/50 )
data |
(1) a vector or list of the names of the data objects used by the model, (2) a (named) list of the data objects themselves, or (3) the name of a "dump" format file containing the data objects, which must end in ".txt", see example below for details. |
inits |
a list with |
parameters.to.save |
character vector of the names of the parameters to save which should be monitored. |
model.file |
file containing the model written in |
n.chains |
number of Markov chains (default: 3) |
n.iter |
number of total iterations per chain (including burn in; default: 2000) |
n.burnin |
length of burn in, i.e. number of iterations to
discard at the beginning. Default is |
n.thin |
thinning rate. Must be a positive integer. Set
|
DIC |
logical; if |
jags.path |
directory that contains the |
working.directory |
sets working directory during execution of this function; This should be the directory where model file is. |
clearWD |
indicating whether the files ‘data.txt’,
‘inits[1:n.chains].txt’, ‘codaIndex.txt’, ‘jagsscript.txt’,
and ‘CODAchain[1:nchains].txt’ should be removed after |
refresh |
refresh frequency for progress bar, default is |
This modifies the jags2 function in R2jags package.
Same as R2jags::jags()
Here's a version that works with log-scale and linear scale axes. The trick is to express line locations in npc coordinates rather than user coordinates, since the latter are of course not linear when axes are on log scales.
line2user(line, side)
line2user(line, side)
line |
integer |
side |
integer; 1-4 |
par('cin')[2] * par('cex') * par('lheight')
returns the current line height
in inches, which we convert to user coordinates by multiplying by
diff(grconvertX(0:1, 'inches', 'user'))
, the length of an inch in user
coordinates (horizontally, in this case - if interested in the vertical
height of a line in user coords we would use
diff(grconvertY(0:1, 'inches', 'user')))
.
a numeric vector of the same length as line
;
the values represent the coordinates in the current plot
and are converted from line
.
https://stackoverflow.com/questions/29125019/get-margin-line-locations-mgp-in-user-coordinates
setup_plot <- function(log = "") { oldpar <- par(mar = c(2, 10, 2, 2), oma = rep(2, 4)) plot.new() plot.window(xlim = c(1, 10), ylim = c(1, 10), log = log) box(which = "plot", lwd = 2, col = "gray40") box(which = "figure", lwd = 2, col = "darkred") box(which = "outer", lwd = 2, col = "darkgreen") text(x = 0.5, y = 0.5, labels = "Plot Region", col = "gray40", font = 2) mtext(side = 3, text = "Figure region", line = 0.5, col = "darkred", font = 2) mtext(side = 3, text = "Device region", line = 2.5, col = "darkgreen", font = 2) for (i in 0:9) { mtext(side = 2, col = "darkred", text = paste0("Line", i), line = i) } par(oldpar) } # And here are a couple of examples, applied to your setup_plot with mar=c(5, 5, 5, 5): setup_plot() axis(1, line=5) axis(2, line=5) abline(h=line2user(0:4, 1), lty=3, xpd=TRUE) abline(v=line2user(0:4, 2), lty=3, xpd=TRUE) abline(h=line2user(0:4, 3), lty=3, xpd=TRUE) abline(v=line2user(0:4, 4), lty=3, xpd=TRUE) setup_plot(log='x') axis(1, line=5) axis(2, line=5) abline(h=line2user(0:4, 1), lty=3, xpd=TRUE) abline(v=line2user(0:4, 2), lty=3, xpd=TRUE) abline(h=line2user(0:4, 3), lty=3, xpd=TRUE) abline(v=line2user(0:4, 4), lty=3, xpd=TRUE) setup_plot(log='y') axis(1, line=5) axis(2, line=5) abline(h=line2user(0:4, 1), lty=3, xpd=TRUE) abline(v=line2user(0:4, 2), lty=3, xpd=TRUE) abline(h=line2user(0:4, 3), lty=3, xpd=TRUE) abline(v=line2user(0:4, 4), lty=3, xpd=TRUE) setup_plot(log='xy') axis(1, line=5) axis(2, line=5) abline(h=line2user(0:4, 1), lty=3, xpd=TRUE) abline(v=line2user(0:4, 2), lty=3, xpd=TRUE) abline(h=line2user(0:4, 3), lty=3, xpd=TRUE) abline(v=line2user(0:4, 4), lty=3, xpd=TRUE)
setup_plot <- function(log = "") { oldpar <- par(mar = c(2, 10, 2, 2), oma = rep(2, 4)) plot.new() plot.window(xlim = c(1, 10), ylim = c(1, 10), log = log) box(which = "plot", lwd = 2, col = "gray40") box(which = "figure", lwd = 2, col = "darkred") box(which = "outer", lwd = 2, col = "darkgreen") text(x = 0.5, y = 0.5, labels = "Plot Region", col = "gray40", font = 2) mtext(side = 3, text = "Figure region", line = 0.5, col = "darkred", font = 2) mtext(side = 3, text = "Device region", line = 2.5, col = "darkgreen", font = 2) for (i in 0:9) { mtext(side = 2, col = "darkred", text = paste0("Line", i), line = i) } par(oldpar) } # And here are a couple of examples, applied to your setup_plot with mar=c(5, 5, 5, 5): setup_plot() axis(1, line=5) axis(2, line=5) abline(h=line2user(0:4, 1), lty=3, xpd=TRUE) abline(v=line2user(0:4, 2), lty=3, xpd=TRUE) abline(h=line2user(0:4, 3), lty=3, xpd=TRUE) abline(v=line2user(0:4, 4), lty=3, xpd=TRUE) setup_plot(log='x') axis(1, line=5) axis(2, line=5) abline(h=line2user(0:4, 1), lty=3, xpd=TRUE) abline(v=line2user(0:4, 2), lty=3, xpd=TRUE) abline(h=line2user(0:4, 3), lty=3, xpd=TRUE) abline(v=line2user(0:4, 4), lty=3, xpd=TRUE) setup_plot(log='y') axis(1, line=5) axis(2, line=5) abline(h=line2user(0:4, 1), lty=3, xpd=TRUE) abline(v=line2user(0:4, 2), lty=3, xpd=TRUE) abline(h=line2user(0:4, 3), lty=3, xpd=TRUE) abline(v=line2user(0:4, 4), lty=3, xpd=TRUE) setup_plot(log='xy') axis(1, line=5) axis(2, line=5) abline(h=line2user(0:4, 1), lty=3, xpd=TRUE) abline(v=line2user(0:4, 2), lty=3, xpd=TRUE) abline(h=line2user(0:4, 3), lty=3, xpd=TRUE) abline(v=line2user(0:4, 4), lty=3, xpd=TRUE)
load an object from .RDATA file
loadOneName(objName, file, envir = parent.frame(), assign.on.exit = TRUE)
loadOneName(objName, file, envir = parent.frame(), assign.on.exit = TRUE)
objName |
the name of the object |
file |
the file path |
envir |
environment; default is calling environment: parent.frame |
assign.on.exit |
default is TRUE |
a new environment
logit function
logit(p)
logit(p)
p |
Probability between 0 and 1 |
A real number
logit(0.5)
logit(0.5)
Case at upper triangle; control at lower triangle
logOR(MBS.case, MBS.ctrl)
logOR(MBS.case, MBS.ctrl)
MBS.case |
Case Bronze-Standard (BrS) data; rows for case subjects;
columns contain |
MBS.ctrl |
Control Bronze-Standard (BrS) data; rows for control subjects;
columns contain |
a list of two elements: logOR
(JBrS
by JBrS
matrix of log
odds ratios for each pair among JBrS
measurements) and logOR.se
(
same dimension as logOR
, but representing the standard errors of the corresponding
estimated log odds ratios in logOR
).
log sum exp trick
logsumexp(x)
logsumexp(x)
x |
a vector of numbers |
a numeric value
logsumexp(c(-20,-30))
logsumexp(c(-20,-30))
Get position to store in data_nplcm$Mobs:
lookup_quality(quality_nm)
lookup_quality(quality_nm)
quality_nm |
names of quality: can be "BrS", "SS" or "GS" |
also works for a vector
position of the quality name: "BrS"-1; "SS"-2; "GS"-3.
Create new file name
make_filename(parameter_names, parameter_vals, format)
make_filename(parameter_names, parameter_vals, format)
parameter_names |
The parameters that distinguish this folder's scenario |
parameter_vals |
The actual parameter values |
format |
The suffix ".XXX" in the end to specify the file format |
A string for file name
make_filename(c("theta","alpha"),c(0.9,2),"csv")
make_filename(c("theta","alpha"),c(0.9,2),"csv")
Create new folder name
make_foldername(parent_path, parameter_names, parameter_vals, sep = "/")
make_foldername(parent_path, parameter_names, parameter_vals, sep = "/")
parent_path |
The parent directory where to put the new folder |
parameter_names |
The parameters that distinguish this folder's scenario |
parameter_vals |
The actual parameter values |
sep |
file name separator - default to |
A string for folder name
make_foldername("/user",c("theta","alpha","beta"),c(1,2,3))
make_foldername("/user",c("theta","alpha","beta"),c(1,2,3))
Roger Peng's listlabeling challenge from http://simplystatistics.tumblr.com/post/11988685443/computing-on-the-language. Code copied from https://gist.github.com/ajdamico/1329117/0134148987859856fcecbe4446cfd37e500e4272
make_list(...)
make_list(...)
... |
any R objects |
a list as described above
#create three example variables for a list x <- 1 y <- 2 z <- "hello" #display the results make_list( x , y , z )
#create three example variables for a list x <- 1 y <- 2 z <- "hello" #display the results make_list( x , y , z )
Wrap the information about a particular type of measurement, e.g., NPPCR. NB: add example! copy some from the vignette file.
make_meas_object(patho, specimen, test, quality, cause_list, sep_char = "_")
make_meas_object(patho, specimen, test, quality, cause_list, sep_char = "_")
patho |
A vector of pathogen names |
specimen |
Specimen name |
test |
Test name |
quality |
Quality category: any of "BrS", "SS" or "GS". |
cause_list |
The vector of potential latent status |
sep_char |
a character string that separate the pathogen names and the
specimen-test pair; Default to |
A list with measurement information
quality
same as argument
patho
same as argument
name_in_data
the names used in the raw data to locate these measurements
template
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.
specimen
same as argument
test
same as argument
nm_spec_test
paste specimen
and test
together
make_meas_object( patho = c("A","B","C","D","E","F"), specimen = "MBS", test = "1", quality = "BrS", cause_list = c("A","B","C","D","E"))
make_meas_object( patho = c("A","B","C","D","E","F"), specimen = "MBS", test = "1", quality = "BrS", cause_list = c("A","B","C","D","E"))
To collect multiple measurements within the same category, e.g., bronze-standard.
make_numbered_list(...)
make_numbered_list(...)
... |
any R object |
a list with names numbered
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)
make_template(patho, cause_list)
patho |
A vector of pathogen names for a particular measurement slice.
|
cause_list |
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", "PARA_3","PARA_4","PV_EV","RHINO","RSV") make_template(patho_BrS_NPPCR,cause_list) cause = c("A","B1","B2","C","A+C","B+C") patho = c("A","B","C") make_template(patho,cause) cause = c("A","B1","B2","C","A+C","B+C","other") patho = c("A","B","C") make_template(patho,cause) cause = c("A","B1","B2","X_B","Y_B","C","A+C","B+C","other") patho = c("A","B","C","X_B","Y_B") make_template(patho,cause)
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", "PARA_3","PARA_4","PV_EV","RHINO","RSV") make_template(patho_BrS_NPPCR,cause_list) cause = c("A","B1","B2","C","A+C","B+C") patho = c("A","B","C") make_template(patho,cause) cause = c("A","B1","B2","C","A+C","B+C","other") patho = c("A","B","C") make_template(patho,cause) cause = c("A","B1","B2","X_B","Y_B","C","A+C","B+C","other") patho = c("A","B","C","X_B","Y_B") make_template(patho,cause)
Shannon entropy for binary data
marg_H(m_px)
marg_H(m_px)
m_px |
a number between 0 and 1 |
a non-negative number
marg_H(0.1)
marg_H(0.1)
@details In our cause_list, "A+B" represents the same cause as "B+A". It is used for plotting side-by-side posterior sample comparisons
match_cause(pattern, vec)
match_cause(pattern, vec)
pattern |
a vector of latent cause names, e.g., from a particular fit |
vec |
a vector of latent cause names, e.g., usually a union of cause names from several model fits. Usually, it is also the display order that one wants to show. |
A vector of length length(vec)
; NA
means no pattern matches
vec; 1 at position 10 means the first element of pattern
matches the
10th element of vec
.
pattern <- c("X+Y","A+Z","C") vec <- c(LETTERS[1:26],"Y+Z","Y+X","Z+A") match_cause(pattern,vec)
pattern <- c("X+Y","A+Z","C") vec <- c(LETTERS[1:26],"Y+Z","Y+X","Z+A") match_cause(pattern,vec)
For a list of many sublists each of which has matrices as its member, we combine across the many sublists to produce a final list
merge_lists(list_of_lists)
merge_lists(list_of_lists)
list_of_lists |
a list of sublists |
a list after merge
Other data operation functions:
combine_data_nplcm()
,
subset_data_nplcm_by_index()
DT1 = list(A=1:3,B=letters[1:3]) DT2 = list(A=4:5,B=letters[4:5]) DT3 = list(A=1:4,B=letters[1:4]) DT4 = list(A=4:7,B=letters[4:7]) l = list(DT1,DT2);names(l) <- c("haha","hihi") l2 = list(DT3,DT4);names(l2) <- c("haha","hihi") listoflists <- list(l,l2);names(listoflists) <- c("dude1","dude2") listoflists merge_lists(listoflists)
DT1 = list(A=1:3,B=letters[1:3]) DT2 = list(A=4:5,B=letters[4:5]) DT3 = list(A=1:4,B=letters[1:4]) DT4 = list(A=4:7,B=letters[4:7]) l = list(DT1,DT2);names(l) <- c("haha","hihi") l2 = list(DT3,DT4);names(l2) <- c("haha","hihi") listoflists <- list(l,l2);names(listoflists) <- c("dude1","dude2") listoflists merge_lists(listoflists)
Reorder the measurement dimensions to match the order for display
my_reorder(disp_order, raw_nm)
my_reorder(disp_order, raw_nm)
disp_order |
The vector of names to be displayed (order matters) |
raw_nm |
The vector of names from raw measurements (order matters) |
A permuted vector from 1 to length(raw_nm)
. For example, if
its first element is 3, it means that the 3rd pathogen in raw_nm
should be arranged to the first in the raw measurements.
disp_order <- c("B","E","D","C","F","A") raw_nm <- c("C","A","E") my_reorder(disp_order,raw_nm)
disp_order <- c("B","E","D","C","F","A") raw_nm <- c("C","A","E") my_reorder(disp_order,raw_nm)
convert 'NA' to '.'
NA2dot(s)
NA2dot(s)
s |
A string of characters that may contain "NA" |
A string of characters without 'NA'
Uses JAGS
(OSX or Windows) operating system for Bayesian posterior inference
(see README
file for an instruction to install JAGS
). If running JAGS
on windows,
please go to control panel to add the directory to JAGS
into ENVIRONMENTAL VARIABLE.
nplcm(data_nplcm, model_options, mcmc_options)
nplcm(data_nplcm, model_options, mcmc_options)
data_nplcm |
Cases are on top of controls in the rows of diagnostic
test results and the covariate matrix. This is assumed by
|
model_options |
A list of model options: likelihood and prior.
|
mcmc_options |
A list of Markov chain Monte Carlo (MCMC) options.
|
A JAGS
output result, fitted by function R2jags::jags2()
from R2jags
.
It is an object of class nplcm
and bugs
.
Current implemented models follow the hierarchy below:
no regression: Fitted by at low level by nplcm_fit_NoReg
regression: Given disease class (control or a class of cases with the same subset of causative agents):
local independence model for BrS measures: Fitted at lower level by
nplcm_fit_Reg_NoNest deals with the setting with two sets of covariates, one for CSCF regression and the other for FPR regression. The two sets of covariates may be identical, overlapping or non-overlapping. This function is called when there exists one or more than one discrete covariate among the union of the two covariate sets. The method implemented by this function directly lets FPR depend upon covariates. This is different from Wu and Chen (2021), which let the subclass weights depend upon covariates. We implemented this function for methods comparison.
nplcm_fit_Reg_discrete_predictor_NoNest deals with the setting with all discrete covariates for FPRs and CSCFs. The strata defined by the two sets of covariates need not be identical, e.g., as a result of distinct sets of covariates. Again, this is directly to let FPR be stratified by covariates, hence different from Wu and Chen (2020+) We implemented this function for methods comparison.
local dependence model for BrS measures: Fitted at lower level by nplcm_fit_Reg_Nest: This is the method introduced in Wu and Chen (2021): CSCF regression + case/control subclass weight regression. It does not provide a specialized function for the setting with all discrete covariates.
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = TRUE, # <- must set to TRUE! <------- NOTE! ppd = FALSE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg)
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = TRUE, # <- must set to TRUE! <------- NOTE! ppd = FALSE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg)
This function prepares data, specifies hyperparameters in priors (true positive rates and etiology fractions), initializes the posterior sampling chain, writes the model file (for JAGS or WinBUGS with slight differences in syntax), and fits the model. Features:
no regression;
no nested subclasses
nplcm_fit_NoReg(data_nplcm, model_options, mcmc_options)
nplcm_fit_NoReg(data_nplcm, model_options, mcmc_options)
data_nplcm |
Cases are on top of controls in the rows of diagnostic
test results and the covariate matrix. This is assumed by
|
model_options |
A list of model options: likelihood and prior.
|
mcmc_options |
A list of Markov chain Monte Carlo (MCMC) options.
|
BUGS fit results.
write_model_NoReg for constructing .bug
model file; This function
then put it in the folder mcmc_options$bugsmodel.dir
.
Other model fitting functions:
nplcm_fit_Reg_Nest()
,
nplcm_fit_Reg_NoNest()
,
nplcm_fit_Reg_discrete_predictor_NoNest()
Fit nested partially-latent class model with regression (low-level)
nplcm_fit_Reg_discrete_predictor_NoNest( data_nplcm, model_options, mcmc_options )
nplcm_fit_Reg_discrete_predictor_NoNest( data_nplcm, model_options, mcmc_options )
data_nplcm |
Cases are on top of controls in the rows of diagnostic
test results and the covariate matrix. This is assumed by
|
model_options |
A list of model options: likelihood and prior.
|
mcmc_options |
A list of Markov chain Monte Carlo (MCMC) options.
|
This function prepares data, specifies hyperparameters in priors (true positive rates and etiology fractions), initializes the posterior sampling chain, writes the model file (for JAGS or WinBUGS with slight differences in syntax), and fits the model. Features:
regression;
no nested subclasses, i.e. conditional independence of multivariate measurements given disease class and covariates;
multiple BrS + multiple SS.
If running JAGS on windows, please go to control panel to add the directory to jags into ENVIRONMENTAL VARIABLE!
BUGS fit results.
write_model_NoReg for automatically generate .bug
model
file; This present function store it in location: mcmc_options$bugsmodel.dir
.
Other model fitting functions:
nplcm_fit_NoReg()
,
nplcm_fit_Reg_Nest()
,
nplcm_fit_Reg_NoNest()
Called by nplcm()
upon being assigned to this nested regression by
assign_model()
nplcm_fit_Reg_Nest(data_nplcm, model_options, mcmc_options)
nplcm_fit_Reg_Nest(data_nplcm, model_options, mcmc_options)
data_nplcm |
Cases are on top of controls in the rows of diagnostic
test results and the covariate matrix. This is assumed by
|
model_options |
A list of model options: likelihood and prior.
|
mcmc_options |
A list of Markov chain Monte Carlo (MCMC) options.
|
This function prepares data, specifies hyperparameters in priors
(true positive rates and etiology fractions), initializes the posterior
sampling chain, writes the model file (for JAGS
), and fits the model. Features:
regression (not all discrete covariates);
nested subclasses, i.e. conditional dependence of multivariate measurements given disease class and covariates;
multiple BrS + multiple SS.
BUGS fit results.
write_model_Reg_Nest for constructing .bug
model file; This function
then put it in the folder mcmc_options$bugsmodel.dir
.
Other model fitting functions:
nplcm_fit_NoReg()
,
nplcm_fit_Reg_NoNest()
,
nplcm_fit_Reg_discrete_predictor_NoNest()
Fit nested partially-latent class model with regression (low-level)
nplcm_fit_Reg_NoNest(data_nplcm, model_options, mcmc_options)
nplcm_fit_Reg_NoNest(data_nplcm, model_options, mcmc_options)
data_nplcm |
Cases are on top of controls in the rows of diagnostic
test results and the covariate matrix. This is assumed by
|
model_options |
A list of model options: likelihood and prior.
|
mcmc_options |
A list of Markov chain Monte Carlo (MCMC) options.
|
This function prepares data, specifies hyperparameters in priors (true positive rates and CSCFs), initializes the posterior sampling chain, writes the model file (for JAGS or WinBUGS with slight differences in syntax), and fits the model. Features:
regression (not all discrete covariates);
no nested subclasses, i.e. conditional independence of multivariate measurements given disease class and covariates;
multiple BrS + multiple SS.
BUGS fit results from JAGS
.
write_model_NoReg for constructing .bug
model file; This function
then puts it in the folder mcmc_options$bugsmodel.dir
.
Other model fitting functions:
nplcm_fit_NoReg()
,
nplcm_fit_Reg_Nest()
,
nplcm_fit_Reg_discrete_predictor_NoNest()
Read data and other model information from a folder that stores model results.
nplcm_read_folder(DIR_NPLCM)
nplcm_read_folder(DIR_NPLCM)
DIR_NPLCM |
File path to the folder containing posterior samples |
A list with data, options and posterior samples.
bugs.dat
model_options
clean_otions
Nd
; Nu
; Y
; Mobs
;
res_nplcm
.
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = FALSE, ppd = TRUE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg) res <- nplcm_read_folder(nplcm_noreg$DIR_NPLCM)
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = FALSE, ppd = TRUE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg) res <- nplcm_read_folder(nplcm_noreg$DIR_NPLCM)
NULL
to zero.null_as_zero
make NULL
to be zero.
null_as_zero(x)
null_as_zero(x)
x |
A number (usually a member of a list) that might be |
A number
order latent status by posterior mean
order_post_eti(res_nplcm, model_options)
order_post_eti(res_nplcm, model_options)
res_nplcm |
result from model fits |
model_options |
model specification |
a list with order (ord
) and ordered posterior samples (by column)
specify overall uniform (symmetric Dirichlet distribution) for etiology prior
overall_uniform(alpha, cause_list)
overall_uniform(alpha, cause_list)
alpha |
any positive number, usually 1. |
cause_list |
a list of latent status |
a vector of length length(cause_list)
Other prior specification functions:
set_prior_tpr_BrS_NoNest()
,
set_prior_tpr_SS()
overall_uniform(1,c("A","B","C"))
overall_uniform(1,c("A","B","C"))
NULL
.parse regression components (either false positive rate or etiology regression)
for fitting npLCM; Only use this when formula is not NULL
.
parse_nplcm_reg(form, data_nplcm, silent = TRUE)
parse_nplcm_reg(form, data_nplcm, silent = TRUE)
form |
regression formula |
data_nplcm |
data object for |
silent |
Default is |
TRUE
for doing regression; FALSE
otherwise.
231 rows indicating bacteria, virus, fungi, or other categories.
data("pathogen_category_perch")
data("pathogen_category_perch")
A matrix of two columns
names of the pathogens
category of the pathogens, B
for
bacterium, V
for virus, F
for fungus, O
for "not categorized"
No returned value; just loading data into the working space.
This is used in simulations where the pathogen names are from the alphabet, and we hope to plot etiologies grouped by virus or bacteria
data("pathogen_category_simulation")
data("pathogen_category_simulation")
A matrix of two columns
names of the hypothetical pathogens, A-Z
category of the hypothetical pathogens, B
for
bacterium, V
for virus, which are randomly assigned.
No returned value; just loading data into the working space.
Plot bronze-standard (BrS) panel
plot_BrS_panel( slice, data_nplcm, model_options, clean_options, bugs.dat, res_nplcm, bg_color, select_latent = NULL, exact = TRUE, top_BrS = 1.3, cexval = 1, srtval = 0, prior_shape = "interval", silent = TRUE )
plot_BrS_panel( slice, data_nplcm, model_options, clean_options, bugs.dat, res_nplcm, bg_color, select_latent = NULL, exact = TRUE, top_BrS = 1.3, cexval = 1, srtval = 0, prior_shape = "interval", silent = TRUE )
slice |
the index of measurement slice for BrS. |
data_nplcm |
See |
model_options |
See |
clean_options |
|
bugs.dat |
Data input for the model fitting. |
res_nplcm |
|
bg_color |
A list with names "BrS", "SS", "pie" to specify background colors |
select_latent |
a vector of character strings representing latent status. It is used for
just plotting a subset of latent status. For example, you can specify |
exact |
Default is |
top_BrS |
Numerical value to specify the rightmost limit on the horizontal axis for the BrS panel. |
cexval |
Default is 1 - size of text of the BrS percentages. |
srtval |
Default is 0 - the direction of the text for the BrS percentages. |
prior_shape |
|
silent |
Default is TRUE to not print any warning messages; FALSE otherwise. |
plotting function.
Other visualization functions:
plot.nplcm()
,
plot_SS_panel()
,
plot_check_common_pattern()
,
plot_check_pairwise_SLORD()
,
plot_etiology_regression()
,
plot_etiology_strat()
,
plot_panels()
,
plot_pie_panel()
,
plot_subwt_regression()
This function is specifically designed for PERCH data, e.g., (NB: dealing with NoA, multiple-pathogen causes, other continuous covariates? also there this function only plots the first slice - so generalization may be useful - give users an option to choose slice s; currently default to the first slice.)
plot_case_study( DIR_NPLCM, stratum_bool = stratum_bool, bugs.dat = NULL, slice = 1, RES_NPLCM = NULL, do_plot = TRUE, do_rug = FALSE, return_metric = TRUE )
plot_case_study( DIR_NPLCM, stratum_bool = stratum_bool, bugs.dat = NULL, slice = 1, RES_NPLCM = NULL, do_plot = TRUE, do_rug = FALSE, return_metric = TRUE )
DIR_NPLCM |
File path to the folder containing posterior samples |
stratum_bool |
integer; for this function, indicates which strata to plot |
bugs.dat |
The posterior samples (loaded into the environment to save time) -> default is NULL |
slice |
integer; specifies which slice of bronze-standard data to visualize; Default to 1. |
RES_NPLCM |
pre-read res_nplcm; default to NULL. |
do_plot |
TRUE for plotting |
do_rug |
TRUE for plotting |
return_metric |
TRUE for showing overall mean etiology, quantiles, s.d., and if |
A figure of etiology regression curves and some marginal positive rate assessment of model fit; See example for the legends.
At each MCMC iteration, we generate a new data set based on the model and parameter values at that iteration. The sample size of the new data set equals that of the actual data set, i.e. the same number of cases and controls.
plot_check_common_pattern( DIR_list, slice_vec = rep(1, length(DIR_list)), n_pat = 10, dodge_val = 0.8 )
plot_check_common_pattern( DIR_list, slice_vec = rep(1, length(DIR_list)), n_pat = 10, dodge_val = 0.8 )
DIR_list |
The list of directory paths, each storing a model output. |
slice_vec |
Default are 1s, for the first slice of BrS data. |
n_pat |
Number of the most common BrS measurement pattern among cases and controls. Default is 10. |
dodge_val |
Default is 0.8; For width of boxplots. |
A figure of posterior predicted frequencies compared with the observed frequencies of the most common patterns for the BrS data.
Other visualization functions:
plot.nplcm()
,
plot_BrS_panel()
,
plot_SS_panel()
,
plot_check_pairwise_SLORD()
,
plot_etiology_regression()
,
plot_etiology_strat()
,
plot_panels()
,
plot_pie_panel()
,
plot_subwt_regression()
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = FALSE, ppd = TRUE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg) plot_check_common_pattern(nplcm_noreg$DIR_NPLCM)
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = FALSE, ppd = TRUE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg) plot_check_common_pattern(nplcm_noreg$DIR_NPLCM)
At each MCMC iteration, we generate a new data set based on the model and parameter values at that iteration. The sample size of the new data set equals that of the actual data set, i.e. the same number of cases and controls.
plot_check_pairwise_SLORD(DIR_NPLCM, slice = 1)
plot_check_pairwise_SLORD(DIR_NPLCM, slice = 1)
DIR_NPLCM |
File path to the folder that stores results from npLCM fit. |
slice |
Default is 1, for the first slice of BrS data. |
A figure of posterior predicted log odds ratio compared with the observed log odds ratio for the BrS data. The function generates this figure in your working directory automatically.
Other visualization functions:
plot.nplcm()
,
plot_BrS_panel()
,
plot_SS_panel()
,
plot_check_common_pattern()
,
plot_etiology_regression()
,
plot_etiology_strat()
,
plot_panels()
,
plot_pie_panel()
,
plot_subwt_regression()
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = FALSE, ppd = TRUE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg) plot_check_pairwise_SLORD(nplcm_noreg$DIR_NPLCM,slice=1)
data(data_nplcm_noreg) cause_list <- LETTERS[1:6] J.BrS <- 6 model_options_no_reg <- list( likelihood = list( cause_list = cause_list, k_subclass = 2, Eti_formula = ~-1, # no covariate for the etiology regression FPR_formula = list( MBS1 = ~-1) # no covariate for the subclass weight regression ), use_measurements = c("BrS"), # use bronze-standard data only for model estimation. prior= list( Eti_prior = overall_uniform(1,cause_list), # Dirichlet(1,...,1) prior for the etiology. TPR_prior = list(BrS = list( info = "informative", # informative prior for TPRs input = "match_range", # specify the informative prior for TPRs by specifying a plausible range. val = list(MBS1 = list(up = list(rep(0.99,J.BrS)), # upper ranges: matched to 97.5% quantile of a Beta prior low = list(rep(0.55,J.BrS)))) # lower ranges: matched to 2.5% quantile of a Beta prior ) ) ) ) set.seed(1) # include stratification information in file name: thedir <- paste0(tempdir(),"_no_reg") # create folders to store the model results dir.create(thedir, showWarnings = FALSE) result_folder_no_reg <- file.path(thedir,paste("results",collapse="_")) thedir <- result_folder_no_reg dir.create(thedir, showWarnings = FALSE) # options for MCMC chains: mcmc_options_no_reg <- list( debugstatus = TRUE, n.chains = 1, n.itermcmc = as.integer(200), n.burnin = as.integer(100), n.thin = 1, individual.pred = FALSE, ppd = TRUE, result.folder = thedir, bugsmodel.dir = thedir ) BrS_object_1 <- make_meas_object(patho = LETTERS[1:6], specimen = "MBS", test = "1", quality = "BrS", cause_list = cause_list) clean_options <- list(BrS_objects = make_list(BrS_object_1)) # place the nplcm data and cleaning options into the results folder dput(data_nplcm_noreg,file.path(thedir,"data_nplcm.txt")) dput(clean_options, file.path(thedir, "data_clean_options.txt")) rjags::load.module("glm") nplcm_noreg <- nplcm(data_nplcm_noreg,model_options_no_reg,mcmc_options_no_reg) plot_check_pairwise_SLORD(nplcm_noreg$DIR_NPLCM,slice=1)
This function visualizes the etiology regression against one continuous covariate, e.g., enrollment date. (NB: dealing with NoA, multiple-pathogen causes, other continuous covariates? also there this function only plots the first slice - so generalization may be useful - give users an option to choose slice s; currently default to the first slice.)
plot_etiology_regression( DIR_NPLCM, stratum_bool, slice = 1, plot_basis = FALSE, truth = NULL, RES_NPLCM = NULL, do_plot = TRUE, do_rug = TRUE, return_metric = TRUE, plot_ma_dots = FALSE )
plot_etiology_regression( DIR_NPLCM, stratum_bool, slice = 1, plot_basis = FALSE, truth = NULL, RES_NPLCM = NULL, do_plot = TRUE, do_rug = TRUE, return_metric = TRUE, plot_ma_dots = FALSE )
DIR_NPLCM |
File path to the folder containing posterior samples |
stratum_bool |
a vector of TRUE/FALSE with TRUE indicating the rows of subjects to include |
slice |
integer; specifies which slice of bronze-standard data to visualize; Default to 1. |
plot_basis |
TRUE for plotting basis functions; Default to FALSE |
truth |
a list of truths computed from true parameters in simulations; elements:
Eti, FPR, PR_case,TPR; All default to
|
RES_NPLCM |
pre-read res_nplcm; default to NULL. |
do_plot |
TRUE for plotting |
do_rug |
TRUE for plotting |
return_metric |
TRUE for showing overall mean etiology, quantiles, s.d., and if |
plot_ma_dots |
plot moving averages among case and controls if TRUE; Default to FALSE. |
A figure of etiology regression curves and some marginal positive rate assessment of model fit; See example for the legends.
See example figures
A Figure using simulated data for six pathogens: https://github.com/zhenkewu/baker/blob/master/inst/figs/visualize_etiology_regression_SITE=1.pdf
The legends for the figure above: https://github.com/zhenkewu/baker/blob/master/inst/figs/legends_visualize_etiology_regression.png
Other visualization functions:
plot.nplcm()
,
plot_BrS_panel()
,
plot_SS_panel()
,
plot_check_common_pattern()
,
plot_check_pairwise_SLORD()
,
plot_etiology_strat()
,
plot_panels()
,
plot_pie_panel()
,
plot_subwt_regression()
This function visualizes the etiology estimates against one discrete covariate, e.g., age groups.
plot_etiology_strat( DIR_NPLCM, strata_weights = "empirical", truth = NULL, RES_NPLCM = NULL, show_levels = 0, is_plot = TRUE, VERBOSE = TRUE )
plot_etiology_strat( DIR_NPLCM, strata_weights = "empirical", truth = NULL, RES_NPLCM = NULL, show_levels = 0, is_plot = TRUE, VERBOSE = TRUE )
DIR_NPLCM |
File path to the folder containing posterior samples |
strata_weights |
a vector of weights that sum to one; for each pathogen
the weights specify how the j-th etiology fraction should be combined across all
levels of the discrete predictors in the data; default is |
truth |
a list of true values, e.g.,
|
RES_NPLCM |
pre-read |
show_levels |
a vector of integers less than or equal to the total number of
levels of strata; default to |
is_plot |
default to TRUE, plotting the figures; if |
VERBOSE |
default to |
plotting function
Other visualization functions:
plot.nplcm()
,
plot_BrS_panel()
,
plot_SS_panel()
,
plot_check_common_pattern()
,
plot_check_pairwise_SLORD()
,
plot_etiology_regression()
,
plot_panels()
,
plot_pie_panel()
,
plot_subwt_regression()
plotting the labels on the left margin for panels plot
plot_leftmost(model_options, height)
plot_leftmost(model_options, height)
model_options |
See |
height |
no. of rows in the panels plot; commonly set as |
a plot
Visualize pairwise log odds ratios (LOR) for data that are available in both cases and controls
plot_logORmat(data_nplcm, pathogen_display, BrS_slice = 1, logOR_rounding = 2)
plot_logORmat(data_nplcm, pathogen_display, BrS_slice = 1, logOR_rounding = 2)
data_nplcm |
See |
pathogen_display |
The pathogen vector in desired order for display.
It can be of larger length than that of |
BrS_slice |
Default is 1 - the set of BrS data to visualize. |
logOR_rounding |
Rounding number of the log odds ratio. Default is 2. |
plot_logORmat
visualizes a matrix of pairwise log odds ratios (LOR)
for cases (upper) and controls (lower). LOR is at the top of the cell.
Below it, its standard error is in smaller type, using the same color as the LOR.
Then the estimate is divided by its standard error. We put the actual value when
the Z-statistics has an absolute value greater than $2$; a plus (red) or minus (blue)
if between $1$ and $2$; blank otherwise.
Figure of LOR matrix and relevant s.e. and significance information.
Other exploratory data analysis functions:
get_top_pattern()
,
show_individual()
,
summarize_BrS()
,
summarize_SS()
,
visualize_season()
data(data_nplcm_noreg) plot_logORmat(data_nplcm_noreg,names(data_nplcm_noreg$Mobs$MBS[[1]]))
data(data_nplcm_noreg) plot_logORmat(data_nplcm_noreg,names(data_nplcm_noreg$Mobs$MBS[[1]]))
plot_panels()
visualizes the model outputs for communicating how the data inform final
latent disease status (etiology). It works for singleton or combo etiologies.
plot_panels( DIR_NPLCM, slices = "all", bg_color = list(BrS = "lavenderblush", SS = "mistyrose", pie = "antiquewhite"), select_latent = NULL, exact = TRUE, SS_upperlimit = 1, eti_upperlimit = 1, silent = TRUE, ref_eti0 = NULL, is_plot = TRUE )
plot_panels( DIR_NPLCM, slices = "all", bg_color = list(BrS = "lavenderblush", SS = "mistyrose", pie = "antiquewhite"), select_latent = NULL, exact = TRUE, SS_upperlimit = 1, eti_upperlimit = 1, silent = TRUE, ref_eti0 = NULL, is_plot = TRUE )
DIR_NPLCM |
File path to the folder containing posterior samples |
slices |
DEFAULT is "all" - to plot all measurements; Otherwise, one can
specify a list: |
bg_color |
A list with names "BrS", "SS", "pie" to specify background colors.
The current default is |
select_latent |
a vector of character strings representing latent status. It is used for
just plotting a subset of latent status. For example, you can specify |
exact |
Default is |
SS_upperlimit |
The upper limit of horizontal bar for the silver-standard subpanel (the middle panel). The default value is .25. |
eti_upperlimit |
The upper limit of horizontal bar for the etiology posterior subpanel (the rightmost panel). The default value is .4 |
silent |
Default is TRUE to not print any warning messages; FALSE otherwise. |
ref_eti0 |
reference quantiles and means; a list: pEti_ref_q, pEti_ref_mean_ord |
is_plot |
default to |
Missing data for BrS or SS are dropped when calculating observed measurement positive rates
A figure with two or three columns (if is_plot=TRUE
); otherwise, it
provide posterior summaries of Etiology information to
used by print.summary.nplcm.no_reg()
Other visualization functions:
plot.nplcm()
,
plot_BrS_panel()
,
plot_SS_panel()
,
plot_check_common_pattern()
,
plot_check_pairwise_SLORD()
,
plot_etiology_regression()
,
plot_etiology_strat()
,
plot_pie_panel()
,
plot_subwt_regression()
Plot etiology (pie) panel
plot_pie_panel( model_options, res_nplcm, bugs.dat, bg_color, select_latent = NULL, exact = TRUE, top_pie = 1, label_size = 1, ref_eti = NULL, is_plot = TRUE )
plot_pie_panel( model_options, res_nplcm, bugs.dat, bg_color, select_latent = NULL, exact = TRUE, top_pie = 1, label_size = 1, ref_eti = NULL, is_plot = TRUE )
model_options |
See |
res_nplcm |
|
bugs.dat |
Data input for the model fitting. |
bg_color |
A list with names "BrS", "SS", "pie" to specify background colors |
select_latent |
a vector of character strings representing latent status. It is used for
just plotting a subset of latent status. For example, you can specify |
exact |
Default is |
top_pie |
Numerical value to specify the rightmost limit on the horizontal axis for the pie panel. |
label_size |
the size of latent status labels on the right margin |
ref_eti |
reference quantiles and means; a list: pEti_ref_q, pEti_ref_mean_ord |
is_plot |
default to |
plotting function.
Other visualization functions:
plot.nplcm()
,
plot_BrS_panel()
,
plot_SS_panel()
,
plot_check_common_pattern()
,
plot_check_pairwise_SLORD()
,
plot_etiology_regression()
,
plot_etiology_strat()
,
plot_panels()
,
plot_subwt_regression()
Plot silver-standard (SS) panel
plot_SS_panel( slice, data_nplcm, model_options, clean_options, bugs.dat, res_nplcm, bg_color, select_latent = NULL, exact = TRUE, top_SS = 1, cexval = 1, srtval = 0, prior_shape = "interval" )
plot_SS_panel( slice, data_nplcm, model_options, clean_options, bugs.dat, res_nplcm, bg_color, select_latent = NULL, exact = TRUE, top_SS = 1, cexval = 1, srtval = 0, prior_shape = "interval" )
slice |
the index of measurement slice for SS. |
data_nplcm |
See |
model_options |
See |
clean_options |
|
bugs.dat |
Data input for the model fitting. |
res_nplcm |
|
bg_color |
A list with names "BrS", "SS", "pie" to specify background colors |
select_latent |
a vector of character strings representing latent status. It is used for
just plotting a subset of latent status. For example, you can specify |
exact |
Default is |
top_SS |
Numerical value to specify the rightmost limit on the horizontal axis for the SS panel. |
cexval |
Default is 1 - size of text of the SS percentages. |
srtval |
Default is 0 - the direction of the text for the SS percentages. |
prior_shape |
|
plotting function
Other visualization functions:
plot.nplcm()
,
plot_BrS_panel()
,
plot_check_common_pattern()
,
plot_check_pairwise_SLORD()
,
plot_etiology_regression()
,
plot_etiology_strat()
,
plot_panels()
,
plot_pie_panel()
,
plot_subwt_regression()
visualize the subclass weight regression with a continuous covariate
plot_subwt_regression( DIR_NPLCM, stratum_bool, case = 0, slice = 1, truth = NULL, RES_NPLCM = NULL )
plot_subwt_regression( DIR_NPLCM, stratum_bool, case = 0, slice = 1, truth = NULL, RES_NPLCM = NULL )
DIR_NPLCM |
File path to the folder containing posterior samples |
stratum_bool |
a vector of TRUE/FALSE with TRUE indicating the rows of subjects to include |
case |
1 for plotting cases, 0 for plotting controls; default to 0. |
slice |
integer; specifies which slice of bronze-standard data to visualize; Default to 1. |
truth |
a list of truths computed from true parameters in simulations; elements:
Eti, FPR, PR_case,TPR; All default to
|
RES_NPLCM |
pre-read res_nplcm; default to NULL. |
A figure of subclass regression curves
Other visualization functions:
plot.nplcm()
,
plot_BrS_panel()
,
plot_SS_panel()
,
plot_check_common_pattern()
,
plot_check_pairwise_SLORD()
,
plot_etiology_regression()
,
plot_etiology_strat()
,
plot_panels()
,
plot_pie_panel()
plot.nplcm
plot the results from nplcm()
.plot.nplcm
plot the results from nplcm()
.
## S3 method for class 'nplcm' plot(x, ...)
## S3 method for class 'nplcm' plot(x, ...)
x |
Output from |
... |
Arguments passed to summary and printing methods. |
a figure
Other visualization functions:
plot_BrS_panel()
,
plot_SS_panel()
,
plot_check_common_pattern()
,
plot_check_pairwise_SLORD()
,
plot_etiology_regression()
,
plot_etiology_strat()
,
plot_panels()
,
plot_pie_panel()
,
plot_subwt_regression()
print.nplcm
summarizes the results from nplcm()
.print.nplcm
summarizes the results from nplcm()
.
## S3 method for class 'nplcm' print(x, ...)
## S3 method for class 'nplcm' print(x, ...)
x |
Output from |
... |
Arguments passed to summary and printing methods. |
Summary of object output by nplcm()
— need details.
Other nplcm results:
print.summary.nplcm.no_reg()
,
print.summary.nplcm.reg_nest_strat()
,
print.summary.nplcm.reg_nest()
,
print.summary.nplcm.reg_nonest_strat()
,
print.summary.nplcm.reg_nonest()
,
summary.nplcm()
nplcm()
model fitsprint.summary.nplcm
is a print method for class
summary.nplcm.NoReg
.
## S3 method for class 'summary.nplcm.no_reg' print(x, ...)
## S3 method for class 'summary.nplcm.no_reg' print(x, ...)
x |
output from |
... |
Not used. |
see print.nplcm()
Other nplcm results:
print.nplcm()
,
print.summary.nplcm.reg_nest_strat()
,
print.summary.nplcm.reg_nest()
,
print.summary.nplcm.reg_nonest_strat()
,
print.summary.nplcm.reg_nonest()
,
summary.nplcm()
nplcm()
model fitsprint.summary.nplcm
is a print method for class
summary.nplcm.reg_nest
.
## S3 method for class 'summary.nplcm.reg_nest' print(x, ...)
## S3 method for class 'summary.nplcm.reg_nest' print(x, ...)
x |
output from |
... |
Not used. |
see print.nplcm()
Other nplcm results:
print.nplcm()
,
print.summary.nplcm.no_reg()
,
print.summary.nplcm.reg_nest_strat()
,
print.summary.nplcm.reg_nonest_strat()
,
print.summary.nplcm.reg_nonest()
,
summary.nplcm()
nplcm()
model fitsSame as print.summary.nplcm.reg_nonest_strat()
## S3 method for class 'summary.nplcm.reg_nest_strat' print(x, ...)
## S3 method for class 'summary.nplcm.reg_nest_strat' print(x, ...)
x |
output from |
... |
Not used. |
print.summary.nplcm
is a print method for class
summary.nplcm.reg_nest_strat
.
see print.nplcm()
Other nplcm results:
print.nplcm()
,
print.summary.nplcm.no_reg()
,
print.summary.nplcm.reg_nest()
,
print.summary.nplcm.reg_nonest_strat()
,
print.summary.nplcm.reg_nonest()
,
summary.nplcm()
nplcm()
model fitsprint.summary.nplcm
is a print method for class
summary.nplcm.reg_nonest
.
## S3 method for class 'summary.nplcm.reg_nonest' print(x, ...)
## S3 method for class 'summary.nplcm.reg_nonest' print(x, ...)
x |
output from |
... |
Not used. |
see print.nplcm()
Other nplcm results:
print.nplcm()
,
print.summary.nplcm.no_reg()
,
print.summary.nplcm.reg_nest_strat()
,
print.summary.nplcm.reg_nest()
,
print.summary.nplcm.reg_nonest_strat()
,
summary.nplcm()
nplcm()
model fitsprint.summary.nplcm
is a print method for class
summary.nplcm.reg_nonest_strat
.
## S3 method for class 'summary.nplcm.reg_nonest_strat' print(x, ...)
## S3 method for class 'summary.nplcm.reg_nonest_strat' print(x, ...)
x |
output from |
... |
Not used. |
see print.nplcm()
Other nplcm results:
print.nplcm()
,
print.summary.nplcm.no_reg()
,
print.summary.nplcm.reg_nest_strat()
,
print.summary.nplcm.reg_nest()
,
print.summary.nplcm.reg_nonest()
,
summary.nplcm()
NB: add example, small data
read_meas_object(object, data)
read_meas_object(object, data)
object |
Outputs from |
data |
Raw data with column names
|
A list with two elements: meas
-data frame with measurements;
position
-see lookup_quality()
Other raw data importing functions:
extract_data_raw()
Sample a vector of Bernoulli variables with higher speed
(same length with "p"
).
The Bernoulli random variables can have different means.
rvbern(p)
rvbern(p)
p |
A vector of probabilities, each being the head probability of an independent coin toss |
A vector of 1s (head) and 0s (tail)
rvbern(c(0.9,0.1,0.2,0.3))
rvbern(c(0.9,0.1,0.2,0.3))
s_date_Eti
creates design matrices for etiology regressions;
s_date_Eti(Rdate, Y, basis = "ps", dof = ifelse(basis == "ncs", 5, 10), ...)
s_date_Eti(Rdate, Y, basis = "ps", dof = ifelse(basis == "ncs", 5, 10), ...)
Rdate |
a vector of dates of |
Y |
Binary case/control status; |
basis |
|
dof |
Degree-of-freedom for the bases. For |
... |
Other arguments as in |
Z_Eti
design matrix for etiology regression on dates.
data("data_nplcm_reg_nest") s_date_Eti(data_nplcm_reg_nest$X$DATE,data_nplcm_reg_nest$Y,basis='ps',dof=7)
data("data_nplcm_reg_nest") s_date_Eti(data_nplcm_reg_nest$X$DATE,data_nplcm_reg_nest$Y,basis='ps',dof=7)
s_date_FPR
creates design matrices for FPR regressions;
s_date_FPR(Rdate, Y, basis = "ps", dof = 10, ...)
s_date_FPR(Rdate, Y, basis = "ps", dof = 10, ...)
Rdate |
a vector of dates of R format |
Y |
Binary case/control status; 1 for case; 0 for controls |
basis |
"ps" for penalized-splines based on B-spline basis functions |
dof |
Degree-of-freedom for the bases.For "ps" basis,
the number of columns is |
... |
Other arguments as in |
Design matrix for FPR regression, with cases' rows on top of controls'.
data(data_nplcm_reg_nest) s_date_FPR(data_nplcm_reg_nest$X$DATE,data_nplcm_reg_nest$Y,basis='ps',dof=7)
data(data_nplcm_reg_nest) s_date_FPR(data_nplcm_reg_nest$X$DATE,data_nplcm_reg_nest$Y,basis='ps',dof=7)
set_prior_tpr_BrS_NoNest
is for for conditional independence models.
We currently also use it for conditional dependence model: subclass TPRs
are independently assigned a beta prior. Ongoing work will enable specifying
priors for the marginal TPR, i.e. TPRs for a disease class, not for the
finer subclass.
set_prior_tpr_BrS_NoNest(slice, model_options, data_nplcm)
set_prior_tpr_BrS_NoNest(slice, model_options, data_nplcm)
slice |
The BrS measurement slice under consideration. |
model_options |
See |
data_nplcm |
See |
Parameters for the BrS dta TPR priors. It is a list of two lists (alpha and beta). Alpha and beta are of the same length, the number of BrS measurement slices. Each element of the alpha (beta) list is a numeric vector for alpha (beta) parameters as in BETA distribution.
Other prior specification functions:
overall_uniform()
,
set_prior_tpr_SS()
Set true positive rate (TPR) prior ranges for silver-standard data.
set_prior_tpr_SS(model_options, data_nplcm)
set_prior_tpr_SS(model_options, data_nplcm)
model_options |
See |
data_nplcm |
See |
Parameters for the SS data TPR priors. It is a list of two lists (alpha and beta). Alpha and beta are of the same length, the number of BrS measurement slices. Each element of the alpha (beta) list is a numeric vector for alpha (beta) parameters to specify Beta prior for TPRs.
Other prior specification functions:
overall_uniform()
,
set_prior_tpr_BrS_NoNest()
set_strat
makes group indicators based on model_options$X_reg_*
set_strat(X, X_reg)
set_strat(X, X_reg)
X |
A data frame of covariates |
X_reg |
The vector of covariates that will stratify the analyses. These variables have to be categorical. |
the results from this function will help stratify etiology or FPR for different strata; the ways of stratification for etiology and FPR can be based on different covariates.
A list with following elements:
N_group
The number of groups
group
A vector of group indicator for every observation
Show function dependencies
show_dep(fname, pckg = "package:baker", ...)
show_dep(fname, pckg = "package:baker", ...)
fname |
Character string for one function |
pckg |
Package name; default is |
... |
Other parameters accepted by |
A figure showing function dependencies
show_dep("nplcm",ancestor=FALSE) show_dep("nplcm")
show_dep("nplcm",ancestor=FALSE) show_dep("nplcm")
clean_perch_data()
get an individual's data from the output of clean_perch_data()
show_individual(data_nplcm, ID)
show_individual(data_nplcm, ID)
data_nplcm |
data for fitting nplcm; See |
ID |
patient id: |
a list with the inquired patient's data
Other exploratory data analysis functions:
get_top_pattern()
,
plot_logORmat()
,
summarize_BrS()
,
summarize_SS()
,
visualize_season()
data(data_nplcm_noreg) data_nplcm_noreg$X$patid <- paste("PAT",1:length(data_nplcm_noreg$Y0),sep="") data_nplcm_noreg$X <- as.data.frame(data_nplcm_noreg$X) subset_data_nplcm_by_index(data_nplcm_noreg,which(data_nplcm_noreg$X$patid%in%c("PAT12","PAT408"))) data_nplcm_noreg$X <- NULL
data(data_nplcm_noreg) data_nplcm_noreg$X$patid <- paste("PAT",1:length(data_nplcm_noreg$Y0),sep="") data_nplcm_noreg$X <- as.data.frame(data_nplcm_noreg$X) subset_data_nplcm_by_index(data_nplcm_noreg,which(data_nplcm_noreg$X$patid%in%c("PAT12","PAT408"))) data_nplcm_noreg$X <- NULL
Simulate Bronze-Standard (BrS) Data
simulate_brs(set_parameter, latent_samples)
simulate_brs(set_parameter, latent_samples)
set_parameter |
True model parameters in an npLCM specification:
|
latent_samples |
simulated latent status for all the subjects, for use in simulating BrS measurements. |
a data frame with first column being case-control status (case at top) and columns of bronze-standard measurements
Other internal simulation functions:
simulate_latent()
,
simulate_ss()
Simulate Latent Status:
simulate_latent(set_parameter)
simulate_latent(set_parameter)
set_parameter |
True model parameters in an npLCM specification:
|
a list of latent status samples for use in simulating measurements. It also includes a template to look up measurement parameters for each disease class.
Other internal simulation functions:
simulate_brs()
,
simulate_ss()
Simulate data from nested partially-latent class model (npLCM) family
simulate_nplcm(set_parameter)
simulate_nplcm(set_parameter)
set_parameter |
True model parameters in an npLCM specification:
|
A list of diagnostic test measurements, true latent statues:
data_nplcm
a list of structured data (see nplcm()
for
description).
template
a matrix: rows for causes (may comprise a single or multiple causative agents), columns for measurements; generated as a lookup table to match disease-class specific parameters (true and false positive rates)
latent_cat
integer values to indicate the latent category. The integer
code corresponds to the order specified in set_parameter$etiology
.
Controls are coded as length(set_parameter$etiology)+1
.)
simulate_latent for simulating discrete latent status, given which simulate_brs simulates bronze-standard data.
K.true <- 2 # no. of latent subclasses in actual simulation. # If eta = c(1,0), effectively, it is K.true=1. J <- 21 # no. of pathogens. N <- 600 # no. of cases/controls. eta <- c(1,0) # if it is c(1,0),then it is conditional independence model, and # only the first column of parameters in PsiBS, ThetaBS matter! seed_start <- 20150202 print(eta) # set fixed simulation sequence: set.seed(seed_start) ThetaBS_withNA <- c(.75,rep(c(.75,.75,.75,NA),5)) PsiBS_withNA <- c(.15,rep(c(.05,.05,.05,NA),5)) ThetaSS_withNA <- c(NA,rep(c(0.15,NA,0.15,0.15),5)) PsiSS_withNA <- c(NA,rep(c(0,NA,0,0),5)) set_parameter <- list( cause_list = c(LETTERS[1:J]), etiology = c(c(0.36,0.1,0.1,0.1,0.1,0.05,0.05,0.05, 0.05,0.01,0.01,0.01,0.01),rep(0.00,8)), #same length as cause_list. pathogen_BrS = LETTERS[1:J][!is.na(ThetaBS_withNA)], pathogen_SS = LETTERS[1:J][!is.na(ThetaSS_withNA)], meas_nm = list(MBS = c("MBS1"),MSS="MSS1"), Lambda = eta, #ctrl mix Eta = t(replicate(J,eta)), #case mix, row number equal to Jcause. PsiBS = cbind(PsiBS_withNA[!is.na(PsiBS_withNA)], rep(0,sum(!is.na(PsiBS_withNA)))), ThetaBS = cbind(ThetaBS_withNA[!is.na(ThetaBS_withNA)], rep(0,sum(!is.na(ThetaBS_withNA)))), PsiSS = PsiSS_withNA[!is.na(PsiSS_withNA)], ThetaSS = ThetaSS_withNA[!is.na(ThetaSS_withNA)], Nu = N, # control size. Nd = N # case size. ) simu_out <- simulate_nplcm(set_parameter) data_nplcm <- simu_out$data_nplcm pathogen_display <- rev(set_parameter$pathogen_BrS) plot_logORmat(data_nplcm,pathogen_display) # more examples are provided in the vignette, including settings with # covariates.
K.true <- 2 # no. of latent subclasses in actual simulation. # If eta = c(1,0), effectively, it is K.true=1. J <- 21 # no. of pathogens. N <- 600 # no. of cases/controls. eta <- c(1,0) # if it is c(1,0),then it is conditional independence model, and # only the first column of parameters in PsiBS, ThetaBS matter! seed_start <- 20150202 print(eta) # set fixed simulation sequence: set.seed(seed_start) ThetaBS_withNA <- c(.75,rep(c(.75,.75,.75,NA),5)) PsiBS_withNA <- c(.15,rep(c(.05,.05,.05,NA),5)) ThetaSS_withNA <- c(NA,rep(c(0.15,NA,0.15,0.15),5)) PsiSS_withNA <- c(NA,rep(c(0,NA,0,0),5)) set_parameter <- list( cause_list = c(LETTERS[1:J]), etiology = c(c(0.36,0.1,0.1,0.1,0.1,0.05,0.05,0.05, 0.05,0.01,0.01,0.01,0.01),rep(0.00,8)), #same length as cause_list. pathogen_BrS = LETTERS[1:J][!is.na(ThetaBS_withNA)], pathogen_SS = LETTERS[1:J][!is.na(ThetaSS_withNA)], meas_nm = list(MBS = c("MBS1"),MSS="MSS1"), Lambda = eta, #ctrl mix Eta = t(replicate(J,eta)), #case mix, row number equal to Jcause. PsiBS = cbind(PsiBS_withNA[!is.na(PsiBS_withNA)], rep(0,sum(!is.na(PsiBS_withNA)))), ThetaBS = cbind(ThetaBS_withNA[!is.na(ThetaBS_withNA)], rep(0,sum(!is.na(ThetaBS_withNA)))), PsiSS = PsiSS_withNA[!is.na(PsiSS_withNA)], ThetaSS = ThetaSS_withNA[!is.na(ThetaSS_withNA)], Nu = N, # control size. Nd = N # case size. ) simu_out <- simulate_nplcm(set_parameter) data_nplcm <- simu_out$data_nplcm pathogen_display <- rev(set_parameter$pathogen_BrS) plot_logORmat(data_nplcm,pathogen_display) # more examples are provided in the vignette, including settings with # covariates.
Simulate Silver-Standard (SS) Data
simulate_ss(set_parameter, latent_samples)
simulate_ss(set_parameter, latent_samples)
set_parameter |
True model parameters in an npLCM specification:
|
latent_samples |
simulated latent status for all the subjects, for use in simulating SS measurements. |
a data frame with first column being case-control status (case at top) and columns of silver-standard measurements
Other internal simulation functions:
simulate_brs()
,
simulate_latent()
uses logsumexp trick to prevent numerical overflow
softmax(x)
softmax(x)
x |
a vector of numbers |
a vector of positive values that sum to one.
softmax2 <- function(x) exp(x) / sum(exp(x)) softmax(c(1, 2, 3) * 1000) # NaN NaN NaN softmax2(c(1, 2, 3) * 1000) # 0 0 1
softmax2 <- function(x) exp(x) / sum(exp(x)) softmax(c(1, 2, 3) * 1000) # NaN NaN NaN softmax2(c(1, 2, 3) * 1000) # 0 0 1
clean_perch_data()
It is particularly useful in simulating data from a regression model where one generates a case and control at a particular covariate value, and just choose a case or control to retain in the simulated data.
subset_data_nplcm_by_index(data_nplcm, index)
subset_data_nplcm_by_index(data_nplcm, index)
data_nplcm |
data for fitting nplcm; See |
index |
a vector of indices indicating the observations you hope to subset; it will subset in all the sublists of data_nplcm |
a list with the requested data, in the order determined by 'index'
Other data operation functions:
combine_data_nplcm()
,
merge_lists()
J = 3 # number of causes cause_list = c(LETTERS[1:J]) # cause list K = 2 # number of subclasses lambda = c(1,0) # subclass weights for control group eta = c(1,0) # subclass weights for case group # setup parameters for the present individual: set_parameter <- list( cause_list = cause_list, etiology = c(0.5,0.2,0.3), # only meaningful for cases pathogen_BrS = LETTERS[1:J], pathogen_SS = LETTERS[1:2], meas_nm = list(MBS = c("MBS1"),MSS=c("MSS1")), Lambda = lambda, # for BrS Eta = t(replicate(J,eta)), # case subclass weight for BrS PsiBS = cbind(c(0.15,0.3,0.35), c(0.25,0.2,0.15)), # FPR PsiSS = cbind(rep(0,J),rep(0,J)), ThetaBS = cbind(c(0.95,0.9,0.85), # TPR c(0.95,0.9,0.85)), ThetaSS = cbind(c(0.25,0.10), c(0.25,0.10)), Nd = 5, Nu = 3 ) simu_out <- simulate_nplcm(set_parameter) out <- simu_out$data_nplcm out subset_data_nplcm_by_index(out,c(1,4,5)) subset_data_nplcm_by_index(out,2)
J = 3 # number of causes cause_list = c(LETTERS[1:J]) # cause list K = 2 # number of subclasses lambda = c(1,0) # subclass weights for control group eta = c(1,0) # subclass weights for case group # setup parameters for the present individual: set_parameter <- list( cause_list = cause_list, etiology = c(0.5,0.2,0.3), # only meaningful for cases pathogen_BrS = LETTERS[1:J], pathogen_SS = LETTERS[1:2], meas_nm = list(MBS = c("MBS1"),MSS=c("MSS1")), Lambda = lambda, # for BrS Eta = t(replicate(J,eta)), # case subclass weight for BrS PsiBS = cbind(c(0.15,0.3,0.35), c(0.25,0.2,0.15)), # FPR PsiSS = cbind(rep(0,J),rep(0,J)), ThetaBS = cbind(c(0.95,0.9,0.85), # TPR c(0.95,0.9,0.85)), ThetaSS = cbind(c(0.25,0.10), c(0.25,0.10)), Nd = 5, Nu = 3 ) simu_out <- simulate_nplcm(set_parameter) out <- simu_out$data_nplcm out subset_data_nplcm_by_index(out,c(1,4,5)) subset_data_nplcm_by_index(out,2)
summarize bronze-standard data
summarize_BrS(BrS_dat, Y)
summarize_BrS(BrS_dat, Y)
BrS_dat |
bronze-standard data, which is usually |
Y |
A vector of case/control status: 1 for case; 0 for control |
a list of summaries for BrS data
Other exploratory data analysis functions:
get_top_pattern()
,
plot_logORmat()
,
show_individual()
,
summarize_SS()
,
visualize_season()
data(data_nplcm_noreg) summarize_BrS(data_nplcm_noreg$Mobs$MBS[[1]], data_nplcm_noreg$Y)
data(data_nplcm_noreg) summarize_BrS(data_nplcm_noreg$Mobs$MBS[[1]], data_nplcm_noreg$Y)
silver-standard data summary
summarize_SS(SS_dat, Y)
summarize_SS(SS_dat, Y)
SS_dat |
a data frame of silver-standard data. It can usually
be obtained by |
Y |
a vector of case control status: 1 for case; 0 for control. |
a vector of number of positives
Other exploratory data analysis functions:
get_top_pattern()
,
plot_logORmat()
,
show_individual()
,
summarize_BrS()
,
visualize_season()
data(data_nplcm_noreg) summarize_BrS(data_nplcm_noreg$Mobs$MBS[[1]], data_nplcm_noreg$Y) summarize_SS(data_nplcm_noreg$Mobs$MSS[[1]], data_nplcm_noreg$Y)
data(data_nplcm_noreg) summarize_BrS(data_nplcm_noreg$Mobs$MBS[[1]], data_nplcm_noreg$Y) summarize_SS(data_nplcm_noreg$Mobs$MSS[[1]], data_nplcm_noreg$Y)
summary.nplcm
summarizes the results from nplcm()
.summary.nplcm
summarizes the results from nplcm()
.
## S3 method for class 'nplcm' summary(object, ...)
## S3 method for class 'nplcm' summary(object, ...)
object |
Output from |
... |
Not used. |
see print.nplcm()
Other nplcm results:
print.nplcm()
,
print.summary.nplcm.no_reg()
,
print.summary.nplcm.reg_nest_strat()
,
print.summary.nplcm.reg_nest()
,
print.summary.nplcm.reg_nonest_strat()
,
print.summary.nplcm.reg_nonest()
sym_diff_month
evaluates the symmetric difference between two sets
of R-formatted date
sym_diff_month(Rdate1, Rdate2)
sym_diff_month(Rdate1, Rdate2)
Rdate1 , Rdate2
|
R-formatted R dates. See |
NULL
if no difference; the set of different months otherwise.
Convert names of pathogen/combinations into 0/1 coding
symb2I(pathogen_name, pathogen_list)
symb2I(pathogen_name, pathogen_list)
pathogen_name |
The allowed pathogen name (can be a combination of pathogens in "pathlist") |
pathogen_list |
The complete list of pathogen names |
A 1 by length(pathlist) matrix of binary code (usually for pathogen presence/absence)
symb2I("A",c("A","B","C")) symb2I("A+B",c("A","B","C")) symb2I("NoA",c("A","B","C")) symb2I(c("A","B+C"),c("A","B","C")) # gives a 2 by 3 matrix.
symb2I("A",c("A","B","C")) symb2I("A+B",c("A","B","C")) symb2I("NoA",c("A","B","C")) symb2I(c("A","B+C"),c("A","B","C")) # gives a 2 by 3 matrix.
generate stick-breaking prior (truncated) from a vector of random probabilities
tsb(u)
tsb(u)
u |
a vector of probabilities, with the last element 1. |
a vector of the same length as u; sum to 1.
oldpar <- graphics::par(mfrow=c(3,3),oma=c(0,1,5,0), mar=c(1,2,1,1)) for (iter in 1:9){ u <- c(rbeta(9,1,0.8),1) res <- tsb(u) barplot(res,ylim=c(0,1),main=paste0("Random Sample #", iter),ylab="Probability") } graphics::mtext("Truncated Stick-Breaking Dist. (10 segments)",3, outer=TRUE,cex=1.5,line=1.5) par(oldpar)
oldpar <- graphics::par(mfrow=c(3,3),oma=c(0,1,5,0), mar=c(1,2,1,1)) for (iter in 1:9){ u <- c(rbeta(9,1,0.8),1) res <- tsb(u) barplot(res,ylim=c(0,1),main=paste0("Random Sample #", iter),ylab="Probability") } graphics::mtext("Truncated Stick-Breaking Dist. (10 segments)",3, outer=TRUE,cex=1.5,line=1.5) par(oldpar)
Convert factor to numeric without losing information on the label
unfactor(f)
unfactor(f)
f |
A factor |
A numeric vector
unfactor(factor(c("1","3","3"),levels=c("1","3"))) # contrast this to: as.numeric(factor(c("1","3","3"),levels=c("1","3")))
unfactor(factor(c("1","3","3"),levels=c("1","3"))) # contrast this to: as.numeric(factor(c("1","3","3"),levels=c("1","3")))
get unique causes, regardless of the actual order in combo
unique_cause(cause_vec)
unique_cause(cause_vec)
cause_vec |
a vector of characters with potential combo repetitions written in scrambled orders separated by "+" |
a vector of characters with unique meanings for latent causes
x <- c("A","B","A","CC+DD","DD+CC","E+F+G","B") unique_cause(x)
x <- c("A","B","A","CC+DD","DD+CC","E+F+G","B") unique_cause(x)
unique_month
converts observed dates into unique months
to help visualize sampled months
unique_month(Rdate)
unique_month(Rdate)
Rdate |
standard date format in R |
a vector of characters with month-year
, e.g., 4-2012
.
Special to case-control visualization: upper right for cases, lower left for controls.
visualize_case_control_matrix( mat, dim_names = ncol(mat), cell_metrics = "", folding_line = TRUE, axes = FALSE, xlab = "", ylab = "", asp = 1, title = "" )
visualize_case_control_matrix( mat, dim_names = ncol(mat), cell_metrics = "", folding_line = TRUE, axes = FALSE, xlab = "", ylab = "", asp = 1, title = "" )
mat |
matrix of values: upper for cases, lower for controls; |
dim_names |
names of the columns, from left to right. It is also the
names of the rows, from bottom to top. Default is 1 through |
cell_metrics |
the meaning of number in every cell; |
folding_line |
Default is |
axes |
plot axes; default is |
xlab |
label for x-axis |
ylab |
label for y-axis |
asp |
aspect ratio; default is |
title |
text for the figure |
plotting function; no returned value.
visualize trend of pathogen observation rate for NPPCR data (both cases and controls)
visualize_season(data_nplcm, patho, slice = 1, slice_SS = 1)
visualize_season(data_nplcm, patho, slice = 1, slice_SS = 1)
data_nplcm |
Data set produced by |
patho |
the index of pathogen |
slice |
the slice of BrS data for visualization; default is 1. |
slice_SS |
the slice of SS data to add onto BrS plots; default is 1, usually representing blood culture measurements. |
This function shows observed
positive rate for continuous covariates,e.g., enrollment date
in PERCH application. Smoothing is done by penalized splines implemented by
mgcv
package. The penalized spline smoothing term is constructed by
mgcv::smooth.construct.ps.smooth.spec()
. The window size of the moving averages currently is set
to 60 days.
A figure with smoothed positive rate and confidence bands for cases and controls, respectively. The right margin shows marginal positive rates; all rates are only among the subset of case subjects who had non-missing responses for a measured agent (e.g., pathogen); similarly for controls.
Other exploratory data analysis functions:
get_top_pattern()
,
plot_logORmat()
,
show_individual()
,
summarize_BrS()
,
summarize_SS()
write_model_NoReg
automatically generates model file according to
model_options
write_model_NoReg( k_subclass, Mobs, prior, cause_list, use_measurements, ppd = NULL, use_jags = FALSE )
write_model_NoReg( k_subclass, Mobs, prior, cause_list, use_measurements, ppd = NULL, use_jags = FALSE )
k_subclass |
the number of subclasses for the slices that require conditional dependence modeling (only applicable to BrS data); its length is of the same value as the number of BrS slices. |
Mobs |
measurement data in the form of |
prior |
prior specification from |
cause_list |
a list of latent status names (crucial for building templates;
see |
use_measurements |
"BrS", or "SS" |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
use_jags |
Default is FALSE; set to TRUE if want to use JAGS for model fitting. |
a long character string to be written into .bug file.
insert_bugfile_chunk_noreg_meas for inserting .bug file chunk for measurements (plug-and-play); insert_bugfile_chunk_noreg_etiology for inserting .bug file chunk for distribution of latent status (etiology).
Other model generation functions:
write_model_Reg_Nest()
,
write_model_Reg_NoNest()
,
write_model_Reg_discrete_predictor_NoNest()
write_model_Reg_discrete_predictor_NoNest
automatically generates model file according to
model_options
write_model_Reg_discrete_predictor_NoNest( Mobs, prior, cause_list, use_measurements, ppd = NULL, use_jags = FALSE )
write_model_Reg_discrete_predictor_NoNest( Mobs, prior, cause_list, use_measurements, ppd = NULL, use_jags = FALSE )
Mobs |
Measurement data in the form of |
prior |
Prior specification from |
cause_list |
A list of latent status names (crucial for building templates;
see |
use_measurements |
"BrS", or "SS" |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
use_jags |
Default is FALSE; set to TRUE if want to use JAGS for model fitting. |
a long character string to be written into .bug file.
insert_bugfile_chunk_noreg_meas for inserting .bug file chunk for measurements (plug-and-play); insert_bugfile_chunk_noreg_etiology for inserting .bug file chunk for distribution of latent status (etiology).
Other model generation functions:
write_model_NoReg()
,
write_model_Reg_Nest()
,
write_model_Reg_NoNest()
.bug
model file for regression model WITH nested subclasseswrite_model_Reg_Nest
automatically generates model file according to
model_options
; This is called within nplcm_fit_Reg_Nest.
write_model_Reg_Nest( Mobs, prior, cause_list, Eti_formula, FPR_formula, use_measurements, ppd = NULL, use_jags = FALSE )
write_model_Reg_Nest( Mobs, prior, cause_list, Eti_formula, FPR_formula, use_measurements, ppd = NULL, use_jags = FALSE )
Mobs |
Measurement data in the form of |
prior |
Prior specification from |
cause_list |
A list of latent status names (crucial for building templates;
see |
Eti_formula |
Etiology regression formula; Check |
FPR_formula |
A list of FPR regression formula; check
|
use_measurements |
"BrS", or "SS" |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
use_jags |
Default is FALSE; set to TRUE if want to use JAGS for model fitting. |
a long character string to be written into .bug file.
insert_bugfile_chunk_noreg_meas for inserting .bug file chunk for measurements (plug-and-play.R); insert_bugfile_chunk_noreg_etiology for inserting .bug file chunk for distribution of latent status (etiology).
Other model generation functions:
write_model_NoReg()
,
write_model_Reg_NoNest()
,
write_model_Reg_discrete_predictor_NoNest()
write_model_Reg_NoNest
automatically generates model file according to
model_options
write_model_Reg_NoNest( Mobs, prior, cause_list, Eti_formula, FPR_formula, use_measurements, ppd = NULL, use_jags = FALSE )
write_model_Reg_NoNest( Mobs, prior, cause_list, Eti_formula, FPR_formula, use_measurements, ppd = NULL, use_jags = FALSE )
Mobs |
Measurement data in the form of |
prior |
Prior specification from |
cause_list |
A list of latent status names (crucial for building templates;
see |
Eti_formula |
Etiology regression formula; Check |
FPR_formula |
A list of FPR regression formula; check
|
use_measurements |
"BrS", or "SS" |
ppd |
Default is NULL; set to TRUE for posterior predictive checking |
use_jags |
Default is FALSE; set to TRUE if want to use JAGS for model fitting. |
a long character string to be written into .bug file.
insert_bugfile_chunk_noreg_meas for inserting .bug file chunk for measurements (plug-and-play); insert_bugfile_chunk_noreg_etiology for inserting .bug file chunk for distribution of latent status (etiology).
Other model generation functions:
write_model_NoReg()
,
write_model_Reg_Nest()
,
write_model_Reg_discrete_predictor_NoNest()
function to write bugs model (copied from R2WinBUGS)
write.model(model, con = "model.bug", digits = 5)
write.model(model, con = "model.bug", digits = 5)
model |
R / S-PLUS function containing the BUGS model in the BUGS model language, for minor differences see Section Details. |
con |
passed to writeLines which actually writes the model file |
digits |
number of significant digits used for WinBUGS input, see formatC |
write text lines to a connection; same as writeLines()