Skip to content

Commit

Permalink
updated naming conventions and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewphamilton committed Apr 8, 2021
1 parent 212264a commit 5705ff3
Show file tree
Hide file tree
Showing 168 changed files with 2,777 additions and 1,986 deletions.
9 changes: 9 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@
^data-raw/vignettes/_AQoL_6D_Syn_Pop\.Rmd$
^doc$
^Meta$
^data-raw/dataverse/abbreviations_lup/abbreviations_lup\.csv$
^data-raw/dataverse/abbreviations_lup/abbreviations_lup\.RDS$
^data-raw/dataverse/fn_type_lup_tb/fn_type_lup_tb\.csv$
^data-raw/dataverse/fn_type_lup_tb/fn_type_lup_tb\.RDS$
^data-raw/MAKE_CLASSES\.R$
^data-raw/MAKE_HOUSESTYLE_DSS\.R$
^data-raw/dataverse/prototype_lup/prototype_lup\.csv$
^data-raw/dataverse/prototype_lup/prototype_lup\.RDS$
^data-raw/extra_abbrs\.txt$
28 changes: 14 additions & 14 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

export("%>%")
export(TTU_predictors_lup)
export(add_cors_and_uts_to_aqol6d_tbs_ls)
export(add_cors_and_utls_to_aqol6d_tbs_ls)
export(add_interval_var)
export(add_labels_to_aqol6d_tb)
export(add_uids_to_tbs_ls)
export(add_utility_predn_to_ds)
export(calculate_dep_var_tfmn)
export(calculate_dpnt_var_tfmn)
export(calculate_rmse)
export(calculate_rmse_tfmn)
export(fit_clg_log_tfmn)
Expand All @@ -23,15 +23,15 @@ export(make_aqol6d_fns_ls)
export(make_aqol6d_items_tb)
export(make_brms_mdl_print_ls)
export(make_brms_mdl_smry_tbl)
export(make_complete_props_tbs_ls)
export(make_complete_prpns_tbs_ls)
export(make_correlated_data_tb)
export(make_corstars_tbl_xx)
export(make_dim_sclg_cons_dbl)
export(make_domain_items_ls)
export(make_fake_ts_data)
export(make_folds_ls)
export(make_item_wrst_wghts_ls_ls)
export(make_knit_pars_ls)
export(make_make_item_wrst_wts_ls_ls)
export(make_mdl)
export(make_mdl_nms_ls)
export(make_mdl_smry_elmt_tbl)
Expand All @@ -44,16 +44,16 @@ export(make_prefd_mdls_vec)
export(make_pt_TTU_predictors_lup)
export(make_shareable_mdl)
export(make_smry_of_brm_mdl)
export(make_smry_of_mdl)
export(make_smry_of_ts_mdl)
export(make_smry_of_mdl_outp)
export(make_smry_of_ts_mdl_outp)
export(make_synth_series_tbs_ls)
export(make_unique_ls_elmt_idx_int)
export(make_vec_with_sum_of_int)
export(make_vec_with_sum_of_int_val)
export(plot_auto_lm)
export(plot_lnr_cmprsn)
export(plot_lnr_cmprsn_sctr_plt)
export(plot_obsd_predd_dnst)
export(plot_obsd_predd_sctr)
export(plot_obsd_predd_sctr_cmprsn)
export(plot_sctr_plt_cmprsn)
export(predict_utility)
export(print_all_plts_for_mdl_set)
export(print_ts_mdl_plts)
Expand All @@ -63,8 +63,8 @@ export(reorder_tbs_for_target_cors)
export(replace_with_missing_vals)
export(scramble_xx)
export(transform_data_tb_for_cmprsn)
export(transform_dep_var_nm)
export(transform_dep_var_nm_for_cll)
export(transform_depnt_var_nm)
export(transform_depnt_var_nm_for_cll)
export(transform_ds_for_mdlng)
export(transform_ds_for_tstng)
export(transform_mdl_vars_with_clss)
Expand All @@ -75,14 +75,14 @@ export(write_all_alg_outps)
export(write_box_cox_tfmn)
export(write_brm_mdl_plt_fl)
export(write_brm_model_plts)
export(write_mdl_cmprsns)
export(write_mdl_cmprsn)
export(write_mdl_plts)
export(write_mdl_type_covars_mdls)
export(write_mdl_type_multi_outps)
export(write_mdl_type_sngl_outps)
export(write_mdls_with_covars_cmprsns)
export(write_mdls_with_covars_cmprsn)
export(write_new_outp_dir)
export(write_predr_and_covars_cmprsns)
export(write_predr_and_covars_cmprsn)
export(write_predr_and_mdl_tstng_results)
export(write_predr_cmprsn_outps)
export(write_results_to_csv)
Expand Down
8 changes: 5 additions & 3 deletions R/C3_TTU_predictors_lup.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ x
#' @description Create a new prototype for the TTU S3 class for candidate predictors lookup table
#' @param short_name_chr Short name (a character vector), Default: character(0)
#' @param long_name_chr Long name (a character vector), Default: character(0)
#' @param min_val_dbl Min value (a double vector), Default: numeric(0)
#' @param max_val_dbl Max value (a double vector), Default: numeric(0)
#' @param min_val_dbl Minimum value (a double vector), Default: numeric(0)
#' @param max_val_dbl Maximum value (a double vector), Default: numeric(0)
#' @param class_chr Class (a character vector), Default: character(0)
#' @param increment_dbl Increment (a double vector), Default: numeric(0)
#' @param class_fn_chr Class function (a character vector), Default: character(0)
#' @param mdl_scaling_dbl Mdl scaling (a double vector), Default: numeric(0)
#' @param mdl_scaling_dbl Model scaling (a double vector), Default: numeric(0)
#' @param covariate_lgl Covariate (a logical vector), Default: logical(0)
#' @return A prototype for TTU S3 class for candidate predictors lookup table
#' @details TTU S3 class for candidate predictors lookup table
Expand Down Expand Up @@ -81,6 +81,7 @@ stop(paste0("TIBBLE must include columns named: ",
names(make_pt_TTU_predictors_lup()) %>% stringr::str_c(sep="", collapse = ", ")),
call. = FALSE)
}

if(!identical(make_pt_TTU_predictors_lup() %>%
dplyr::summarise_all(class) %>%
tidyr::gather(variable,class) %>%
Expand All @@ -102,6 +103,7 @@ dplyr::pull(2),
stringr::str_c(sep="", collapse = ", ")),
call. = FALSE)
}

x}
#' Is TTU S3 class for candidate predictors lookup table
#' @description Check whether an object is a valid instance of the TTU S3 class for candidate predictors lookup table
Expand Down
1 change: 1 addition & 0 deletions R/db_abbreviations_lup.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
#' \item{long_name_chr}{Long name (a character vector)}
#' \item{plural_lgl}{Plural (a logical vector)}
#' }
#' @source \url{https://doi.org/10.7910/DVN/2Y9VF9}
"abbreviations_lup"
1 change: 1 addition & 0 deletions R/db_fn_type_lup_tb.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
#' \item{is_generic_lgl}{Is generic (a logical vector)}
#' \item{is_method_lgl}{Is method (a logical vector)}
#' }
#' @source \url{https://doi.org/10.7910/DVN/2Y9VF9}
"fn_type_lup_tb"
4 changes: 2 additions & 2 deletions R/db_mdl_types_lup.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#' \item{family_chr}{Family (a character vector)}
#' \item{fn_chr}{Function (a character vector)}
#' \item{start_chr}{Start (a character vector)}
#' \item{pred_type_chr}{Pred type (a character vector)}
#' \item{predn_type_chr}{Prediction type (a character vector)}
#' \item{tfmn_chr}{Transformation (a character vector)}
#' \item{tfmn_for_bnml_lgl}{Transformation for bnml (a logical vector)}
#' \item{tfmn_for_bnml_lgl}{Transformation for binomial (a logical vector)}
#' }
"mdl_types_lup"
4 changes: 2 additions & 2 deletions R/db_predictors_lup.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#' \describe{
#' \item{short_name_chr}{Short name (a character vector)}
#' \item{long_name_chr}{Long name (a character vector)}
#' \item{min_val_dbl}{Min value (a double vector)}
#' \item{max_val_dbl}{Max value (a double vector)}
#' \item{min_val_dbl}{Minimum value (a double vector)}
#' \item{max_val_dbl}{Maximum value (a double vector)}
#' \item{class_chr}{Class (a character vector)}
#' \item{increment_dbl}{Increment (a double vector)}
#' \item{class_fn_chr}{Class function (a character vector)}
Expand Down
4 changes: 2 additions & 2 deletions R/db_prototype_lup.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#'
#' \describe{
#' \item{type_chr}{Type (a character vector)}
#' \item{val_chr}{Val (a character vector)}
#' \item{val_chr}{Value (a character vector)}
#' \item{pt_ns_chr}{Prototype namespace (a character vector)}
#' \item{fn_to_call_chr}{Function to call (a character vector)}
#' \item{default_val_chr}{Default val (a character vector)}
#' \item{default_val_chr}{Default value (a character vector)}
#' \item{old_class_lgl}{Old class (a logical vector)}
#' }
"prototype_lup"
6 changes: 3 additions & 3 deletions R/db_rprt_lup.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#' \describe{
#' \item{rprt_nms_chr}{Report names (a character vector)}
#' \item{title_chr}{Title (a character vector)}
#' \item{paths_to_RMD_dir_1L_chr}{Paths toMD directory (a character vector of length one)}
#' \item{paths_to_rmd_dir_1L_chr}{Paths to Markdown directory (a character vector of length one)}
#' \item{pkg_dirs_chr}{Package directories (a character vector)}
#' \item{packages_chr}{Packages (a character vector)}
#' \item{nms_of_RMD_chr}{Names ofMD (a character vector)}
#' \item{rltv_paths_to_outpt_yaml_chr}{Rltv paths to outpt yaml (a character vector)}
#' \item{nms_of_rmd_chr}{Names of Markdown (a character vector)}
#' \item{rltv_paths_to_outpt_yaml_chr}{Relative paths to outpt yaml (a character vector)}
#' }
"rprt_lup"
62 changes: 31 additions & 31 deletions R/fn_add.R
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
#' Add correlations and utilities to Assessment of Quality of Life Six Dimension tibbles
#' @description add_cors_and_uts_to_aqol6d_tbs_ls() is an Add function that updates an object by adding data to that object. Specifically, this function implements an algorithm to add correlations and utilities to assessment of quality of life six dimension tibbles list. Function argument aqol6d_tbs_ls specifies the object to be updated. The function returns Assessment of Quality of Life Six Dimension tibbles (a list).
#' @description add_cors_and_utls_to_aqol6d_tbs_ls() is an Add function that updates an object by adding data to that object. Specifically, this function implements an algorithm to add correlations and utilities to assessment of quality of life six dimension tibbles list. Function argument aqol6d_tbs_ls specifies the object to be updated. The function returns Assessment of Quality of Life Six Dimension tibbles (a list).
#' @param aqol6d_tbs_ls Assessment of Quality of Life Six Dimension tibbles (a list)
#' @param aqol_scores_pars_ls Assessment of Quality of Life scores parameters (a list)
#' @param aqol_items_props_tbs_ls Assessment of Quality of Life items props tibbles (a list)
#' @param aqol_items_prpns_tbs_ls Assessment of Quality of Life items proportions tibbles (a list)
#' @param temporal_cors_ls Temporal correlations (a list)
#' @param prefix_chr Prefix (a character vector)
#' @param aqol_tots_var_nms_chr Assessment of Quality of Life totals var names (a character vector)
#' @param id_var_nm_1L_chr Id var name (a character vector of length one), Default: 'fkClientID'
#' @param aqol_tots_var_nms_chr Assessment of Quality of Life totals variable names (a character vector)
#' @param id_var_nm_1L_chr Identity variable name (a character vector of length one), Default: 'fkClientID'
#' @return Assessment of Quality of Life Six Dimension tibbles (a list)
#' @rdname add_cors_and_uts_to_aqol6d_tbs_ls
#' @rdname add_cors_and_utls_to_aqol6d_tbs_ls
#' @export

#' @keywords internal
add_cors_and_uts_to_aqol6d_tbs_ls <- function (aqol6d_tbs_ls, aqol_scores_pars_ls, aqol_items_props_tbs_ls,
add_cors_and_utls_to_aqol6d_tbs_ls <- function (aqol6d_tbs_ls, aqol_scores_pars_ls, aqol_items_prpns_tbs_ls,
temporal_cors_ls, prefix_chr, aqol_tots_var_nms_chr, id_var_nm_1L_chr = "fkClientID")
{
aqol6d_tbs_ls <- reorder_tbs_for_target_cors(aqol6d_tbs_ls,
cor_dbl = temporal_cors_ls[[1]], cor_var_chr = rep(names(temporal_cors_ls)[1],
2), id_var_to_rm_1L_chr = "id") %>% add_uids_to_tbs_ls(prefix_1L_chr = prefix_chr[["uid"]],
id_var_nm_1L_chr = id_var_nm_1L_chr)
aqol6d_tbs_ls <- aqol6d_tbs_ls %>% add_aqol6d_items_to_aqol6d_tbs_ls(aqol_items_props_tbs_ls = aqol_items_props_tbs_ls,
aqol6d_tbs_ls <- aqol6d_tbs_ls %>% add_aqol6d_items_to_aqol6d_tbs_ls(aqol_items_prpns_tbs_ls = aqol_items_prpns_tbs_ls,
prefix_chr = prefix_chr, aqol_tots_var_nms_chr = aqol_tots_var_nms_chr,
id_var_nm_1L_chr = id_var_nm_1L_chr)
return(aqol6d_tbs_ls)
}
#' Add interval var
#' @description add_interval_var() is an Add function that updates an object by adding data to that object. Specifically, this function implements an algorithm to add interval var. Function argument data_tb specifies the object to be updated. The function returns Updated data (a tibble).
#' Add interval variable
#' @description add_interval_var() is an Add function that updates an object by adding data to that object. Specifically, this function implements an algorithm to add interval variable. Function argument data_tb specifies the object to be updated. The function returns Updated data (a tibble).
#' @param data_tb Data (a tibble)
#' @param id_var_nm_1L_chr Id var name (a character vector of length one), Default: 'fkClientID'
#' @param msrmnt_date_var_nm_1L_chr Msrmnt date var name (a character vector of length one), Default: 'd_interview_date'
#' @param id_var_nm_1L_chr Identity variable name (a character vector of length one), Default: 'fkClientID'
#' @param msrmnt_date_var_nm_1L_chr Measurement date variable name (a character vector of length one), Default: 'd_interview_date'
#' @param time_unit_1L_chr Time unit (a character vector of length one), Default: 'days'
#' @param bl_date_var_nm_1L_chr Bl date var name (a character vector of length one), Default: 'bl_date_dtm'
#' @param interval_var_nm_1L_chr Interval var name (a character vector of length one), Default: 'interval_dbl'
#' @param temp_row_nbr_var_nm_1L_chr Temp row nbr var name (a character vector of length one), Default: 'temp_row_nbr_int'
#' @param drop_bl_date_var PARAM_DESCRIPTION, Default: F
#' @param bl_date_var_nm_1L_chr Baseline date variable name (a character vector of length one), Default: 'bl_date_dtm'
#' @param interval_var_nm_1L_chr Interval variable name (a character vector of length one), Default: 'interval_dbl'
#' @param temp_row_nbr_var_nm_1L_chr Temporary row number variable name (a character vector of length one), Default: 'temp_row_nbr_int'
#' @param drop_bl_date_var_1L_lgl Drop baseline date variable (a logical vector of length one), Default: F
#' @return Updated data (a tibble)
#' @rdname add_interval_var
#' @export
Expand All @@ -44,7 +44,7 @@ add_cors_and_uts_to_aqol6d_tbs_ls <- function (aqol6d_tbs_ls, aqol_scores_pars_l
add_interval_var <- function (data_tb, id_var_nm_1L_chr = "fkClientID", msrmnt_date_var_nm_1L_chr = "d_interview_date",
time_unit_1L_chr = "days", bl_date_var_nm_1L_chr = "bl_date_dtm",
interval_var_nm_1L_chr = "interval_dbl", temp_row_nbr_var_nm_1L_chr = "temp_row_nbr_int",
drop_bl_date_var = F)
drop_bl_date_var_1L_lgl = F)
{
updated_data_tb <- data_tb %>% dplyr::ungroup() %>% dplyr::mutate(`:=`(!!rlang::sym(temp_row_nbr_var_nm_1L_chr),
1:dplyr::n())) %>% dplyr::group_by(!!rlang::sym(id_var_nm_1L_chr)) %>%
Expand All @@ -56,7 +56,7 @@ add_interval_var <- function (data_tb, id_var_nm_1L_chr = "fkClientID", msrmnt_d
.y) %>% lubridate::time_length(unit = time_unit_1L_chr))) %>%
dplyr::ungroup() %>% dplyr::arrange(!!rlang::sym(temp_row_nbr_var_nm_1L_chr)) %>%
dplyr::select(-!!rlang::sym(temp_row_nbr_var_nm_1L_chr))
if (drop_bl_date_var)
if (drop_bl_date_var_1L_lgl)
updated_data_tb <- updated_data_tb %>% dplyr::select(-!!rlang::sym(bl_date_var_nm_1L_chr))
return(updated_data_tb)
}
Expand Down Expand Up @@ -108,7 +108,7 @@ add_labels_to_aqol6d_tb <- function (aqol6d_tb, labels_chr = NA_character_)
#' @description add_uids_to_tbs_ls() is an Add function that updates an object by adding data to that object. Specifically, this function implements an algorithm to add unique identifiers to tibbles list. Function argument tbs_ls specifies the object to be updated. The function returns Tibbles (a list).
#' @param tbs_ls Tibbles (a list)
#' @param prefix_1L_chr Prefix (a character vector of length one)
#' @param id_var_nm_1L_chr Id var name (a character vector of length one), Default: 'fkClientID'
#' @param id_var_nm_1L_chr Identity variable name (a character vector of length one), Default: 'fkClientID'
#' @return Tibbles (a list)
#' @rdname add_uids_to_tbs_ls
#' @export
Expand All @@ -135,43 +135,43 @@ add_uids_to_tbs_ls <- function (tbs_ls, prefix_1L_chr, id_var_nm_1L_chr = "fkCli
#' Add utility prediction to dataset
#' @description add_utility_predn_to_ds() is an Add function that updates an object by adding data to that object. Specifically, this function implements an algorithm to add utility prediction to dataset. Function argument data_tb specifies the object to be updated. The function returns Data (a tibble).
#' @param data_tb Data (a tibble)
#' @param model_mdl PARAM_DESCRIPTION
#' @param model_mdl Model (a model)
#' @param tfmn_1L_chr Transformation (a character vector of length one)
#' @param dep_var_nm_1L_chr Dep var name (a character vector of length one)
#' @param predr_vars_nms_chr Predr vars names (a character vector), Default: NULL
#' @param force_min_max_1L_lgl Force min max (a logical vector of length one), Default: T
#' @param utl_min_val_1L_dbl Utl min value (a double vector of length one), Default: 0.03
#' @param depnt_var_nm_1L_chr Dependent variable name (a character vector of length one)
#' @param predr_vars_nms_chr Predictor variables names (a character vector), Default: NULL
#' @param force_min_max_1L_lgl Force minimum maximum (a logical vector of length one), Default: T
#' @param utl_min_val_1L_dbl Utility minimum value (a double vector of length one), Default: 0.03
#' @param impute_1L_lgl Impute (a logical vector of length one), Default: T
#' @param utl_cls_fn Utl class (a function), Default: NULL
#' @param rmv_tfmd_dep_var_1L_lgl Rmv tfmd dep var (a logical vector of length one), Default: F
#' @param utl_cls_fn Utility class (a function), Default: NULL
#' @param rmv_tfd_depnt_var_1L_lgl Remove transformed dependent variable (a logical vector of length one), Default: F
#' @return Data (a tibble)
#' @rdname add_utility_predn_to_ds
#' @export
#' @importFrom purrr reduce map flatten_chr
#' @importFrom dplyr mutate select
#' @importFrom rlang sym
#' @importFrom tidyselect all_of
add_utility_predn_to_ds <- function (data_tb, model_mdl, tfmn_1L_chr, dep_var_nm_1L_chr,
add_utility_predn_to_ds <- function (data_tb, model_mdl, tfmn_1L_chr, depnt_var_nm_1L_chr,
predr_vars_nms_chr = NULL, force_min_max_1L_lgl = T, utl_min_val_1L_dbl = 0.03,
impute_1L_lgl = T, utl_cls_fn = NULL, rmv_tfmd_dep_var_1L_lgl = F)
impute_1L_lgl = T, utl_cls_fn = NULL, rmv_tfd_depnt_var_1L_lgl = F)
{
dep_vars_chr <- c(dep_var_nm_1L_chr, transform_dep_var_nm(dep_var_nm_1L_chr = dep_var_nm_1L_chr,
dep_vars_chr <- c(depnt_var_nm_1L_chr, transform_depnt_var_nm(depnt_var_nm_1L_chr = depnt_var_nm_1L_chr,
tfmn_1L_chr = tfmn_1L_chr)) %>% unique()
data_tb <- purrr::reduce(dep_vars_chr, .init = data_tb, ~dplyr::mutate(.x,
`:=`(!!rlang::sym(.y), NA_real_)))
predictions_dbl <- predict_utility(data_tb = data_tb, tfmn_1L_chr = tfmn_1L_chr,
model_mdl = model_mdl, force_min_max_1L_lgl = force_min_max_1L_lgl,
utl_min_val_1L_dbl = utl_min_val_1L_dbl, impute_1L_lgl = impute_1L_lgl,
utl_cls_fn = utl_cls_fn)
data_tb <- data_tb %>% dplyr::mutate(`:=`(!!rlang::sym(dep_var_nm_1L_chr),
data_tb <- data_tb %>% dplyr::mutate(`:=`(!!rlang::sym(depnt_var_nm_1L_chr),
predictions_dbl))
if (!is.null(predr_vars_nms_chr)) {
data_tb <- data_tb %>% dplyr::select(-tidyselect::all_of(purrr::map(predr_vars_nms_chr,
~paste0(.x, c("_baseline", "_change"))) %>% purrr::flatten_chr()))
}
if (rmv_tfmd_dep_var_1L_lgl) {
if (rmv_tfd_depnt_var_1L_lgl) {
data_tb <- data_tb %>% dplyr::select(-tidyselect::all_of(dep_vars_chr[dep_vars_chr !=
dep_var_nm_1L_chr]))
depnt_var_nm_1L_chr]))
}
return(data_tb)
}
Loading

0 comments on commit 5705ff3

Please sign in to comment.