library(ready4)
library(ready4fun)
library(ready4show)
library(ready4use)
library(youthvars)
library(scorz)
library(cmdstanr)
fns_env_ls <- ready4fun::read_fns(c("data-raw/fns/","data-raw/mthds/"),
fns_env = new.env(parent = globalenv()))
x <- ready4fun::make_pkg_desc_ls(pkg_title_1L_chr = "Specify Models To Solve Inverse Problems" %>% tools::toTitleCase(),
pkg_desc_1L_chr = "Modules from the ready4 youth mental health economic model (https://www.ready4-dev.com/docs/model/) that can be used to standardise the formalising and testing of models to solve inverse problems. Designed for use in models developed with the ready4 framework (https://www.ready4-dev.com/).
This development version of the specific package has been made available as part of the process of testing and documenting the package.
If you have any questions, please contact the authors (matthew.hamilton1@monash.edu).",
authors_prsn = c(utils::person(given = "Matthew",family = "Hamilton",email = "matthew.hamilton1@monash.edu", role = c("aut", "cre"),comment = c(ORCID = "0000-0001-7407-9194")),
utils::person(given = "Caroline",family = "Gao",email = "caroline.gao@orygen.org.au", role = c("aut"),comment = c(ORCID = "0000-0002-0987-2759")),
utils::person("Orygen", role = c("cph", "fnd")),
utils::person("Headspace", role = c( "fnd")),
utils::person("National Health and Medical Research Council", role = c("fnd"))),
urls_chr = c("https://ready4-dev.github.io/specific/",
"https://github.com/ready4-dev/specific",
"https://www.ready4-dev.com/")) %>%
ready4fun::make_manifest(addl_pkgs_ls = ready4fun::make_addl_pkgs_ls(depends_chr = c("ggfortify"),
suggests_chr = c("rmarkdown"),#,"scorz"
imports_chr = c("knitrBootstrap")),
build_ignore_ls = ready4fun::make_build_ignore_ls(file_nms_chr = c("initial_setup.R")),
check_type_1L_chr = "ready4",
copyright_holders_chr = "Orygen",
custom_dmt_ls = ready4fun::make_custom_dmt_ls(user_manual_fns_chr = c("get_background_text",
"get_cndts_for_mxd_mdls",
"get_conclusion_text",
"get_covar_ctgs",
"get_covars_by_ctg",
"get_link_from_tfmn",
"get_mdl_cmprsns",
"get_mdl_type_from_nm",
"get_mdls_with_signft_covars",
"get_nbr_of_predrs",
"get_nbr_of_predrs_by_ctg",
"get_nbr_of_scndry_analyses",
"get_ordered_sngl_csnl_mdls",
"get_popl_descvs",
"get_predr_ctgs",
"get_predrs_by_ctg",
"get_prefd_mdl_predrs",
"get_scndry_anlys_descs",
"get_selected_mixed_mdls",
"get_signft_covars",
"make_abstract_args_ls",
"make_analysis_ds_smry_ls",
"make_cmpst_sctr_and_dnst_plt",
"make_cndt_predr_text",
"make_coi_text",
"make_correlation_text",
"make_covariates_text",
"make_data_availability_text",
"make_dnst_and_sctr_plt_title",
"make_ds_descvs_ls",
"make_ds_smry_ls",
"make_ethics_text",
"make_fake_ts_data",
"make_funding_text",
#"make_header_yaml_args_ls",
"make_indpnt_predrs_lngl_tbl_title",
"make_indpnt_predrs_lngl_tbls_ref",
"make_input_params",
"make_knit_pars_ls",
"make_maui_params_ls",
"make_mdl",
"make_mdl_coef_range_text",
"make_mdl_desc_lines",
"make_nbr_at_fup_text",
"make_nbr_included_text",
"make_output_format_ls",
"make_path_params_ls",
"make_predr_vals",
"make_predr_vars_nms_ls",
"make_predrs_for_best_mdls",
"make_prefd_mdls_vec",
"make_prefd_mdls_vec",
"make_random_forest_text",
"make_results_ls",
"make_scaling_text",
"make_scndry_anlys_params",
"make_scndry_anlys_text",
"make_selected_mdl_text",
"make_shareable_mdl",
"make_study_descs_ls",
"make_ten_fold_text",
"make_ten_folds_tbl_title",
"make_tfmn_cmprsn_plt",
"make_within_between_ratios_text",
"predict_vals",
"print_all_plts_for_mdl_set",
"print_cohort_table",
"print_cors_tbl",
"print_covar_ttu_tbls",
"print_indpnt_predrs_coefs_tbl",
"print_indpnt_predrs_lngl_mdl_coefs",
"print_ten_folds_tbl",
"print_ts_mdl_plts",
"reorder_cndt_predrs_chr",
"transform_tb_to_mdl_inp",
"transform_data_tb_for_cmprsn",
"transform_ds_for_mdlng",
"transform_ds_to_predn_ds",
"transform_mdl_vars_with_clss",
"transform_tb_to_mdl_inp",
"write_analyses",
#"write_csp_output",
#"write_main_outp_dir",
#"write_manuscript",
"write_mdl_cmprsn",
"write_mdl_type_covars_mdls",
"write_mdl_type_multi_outps",
"write_mdls_with_covars_cmprsn",
"write_predr_and_covars_cmprsn",
"write_predr_cmprsn_outps",
#"write_report",
#"write_reporting_dir",
"write_shareable_mdls",
"write_sngl_predr_multi_mdls_outps",
"write_to_delete_ds_copies",
"write_to_delete_mdl_fls",
"write_ts_mdls_from_alg_outp")
),##
dev_pkgs_chr = c("ready4",
"ready4use","ready4show",
"youthvars","scorz"),
lifecycle_stage_1L_chr = "experimental",
path_to_pkg_logo_1L_chr = "../../../../../Documentation/Images/specific-logo/default.png",
piggyback_to_1L_chr = "ready4-dev/ready4",
ready4_type_1L_chr = "modelling",
zenodo_badge_1L_chr = "[](https://doi.org/10.5281/zenodo.5768689)"
)
## y
y <- dplyr::bind_rows(ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Parameters",
slots_ls = list(#"a_ScorzProfile",
"candidate_mdls_chr",
"candidate_mdls_lup",
"candidate_mdl_pfcs_chr",
"candidate_predrs_chr",
"candidate_covars_chr",
"control_ls", #
"depnt_var_nm_1L_chr",
"depnt_var_min_max_dbl",
"descv_var_nms_chr", #1
"domain_labels_chr",
"fake_1L_lgl", #2
"folds_1L_int",
"itm_labels_chr", #3
"itm_prefix_1L_chr", #4
"iters_1L_int", #
"max_mdl_runs_1L_int",
"msrmnt_date_var_nm_1L_chr", #5
"paths_ls",# 6
"prior_ls",#
"seed_1L_int",
"total_unwtd_var_nm_1L_chr", #7
"predictors_lup") %>% list(),
pt_ls = list(#"ScorzProfile",
"character",
"specific_models",
"character",
"character",
"character",
"list",
"character",
"numeric",
"character",#1
"character",
"logical",#2
"integer",
"character",#3
"character",#4
"integer",
"integer",
"character",#5
"list", # 6
"list",
"integer",
"character",#7
"specific_predictors") %>% list(),
vals_ls = list(list(candidate_mdls_lup = "get_cndt_mdls()",
fake_1L_lgl = "F",
folds_1L_int = "10L",
iters_1L_int = "4000L",
max_mdl_runs_1L_int = "300L",
seed_1L_int = "1234L")),
#vals_ls = list(list(instrument_version_1L_chr = "'Adolescent'")),
class_desc_chr = "Input parameters that specify candidate models to be explored.",
parent_class_chr = "Ready4Module"#,inc_clss_ls = list("ScorzAqol6")
),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Private",
slots_ls = list("private_outp_ls") %>% list(),
pt_ls = list("list") %>% list(),
class_desc_chr = "Analysis outputs not intended for public dissemination.",
parent_class_chr = "Ready4Private"),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Shareable",
slots_ls = list("shareable_outp_ls") %>% list(),
pt_ls = list("list") %>% list(),
class_desc_chr = "Analysis outputs intended for public dissemination.",
parent_class_chr = "Ready4Public"),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Results",
slots_ls = list("a_SpecificShareable",
"b_SpecificPrivate") %>% list(),
pt_ls = list("SpecificShareable",
"SpecificPrivate") %>% list(),
class_desc_chr = "Analysis results.",
parent_class_chr = "Ready4Module",
inc_clss_ls = list("SpecificShareable","SpecificPrivate") %>% list()),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Project",
slots_ls = list("a_YouthvarsProfile",
"b_SpecificParameters",
"c_SpecificResults",
"paths_chr") %>% list(),
pt_ls = list("YouthvarsProfile",
"SpecificParameters",
"SpecificResults",
"character") %>% list(),
class_desc_chr = "Modelling project dataset, parameters and results.",
parent_class_chr = "Ready4Module",
inc_clss_ls = list("SpecificResults","SpecificParameters") %>% list()),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Initiator",
slots_ls = list("a_YouthvarsProfile",
"b_SpecificParameters",
"c_SpecificResults",
"paths_chr") %>% list(),
pt_ls = list("YouthvarsProfile",
"SpecificParameters",
"SpecificResults",
"character") %>% list(),
class_desc_chr = "Modelling project dataset, input parameters and empty results placeholder.",
parent_class_chr = "SpecificProject",
inc_clss_ls = list("SpecificResults","SpecificParameters") %>% list()),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Models",
slots_ls = list("a_YouthvarsProfile",
"b_SpecificParameters",
"c_SpecificResults",
"paths_chr") %>% list(),
pt_ls = list("YouthvarsProfile",
"SpecificParameters",
"SpecificResults",
"character") %>% list(),
class_desc_chr = "Modelling project dataset, input parameters and model comparison results.",
parent_class_chr = "SpecificProject",
inc_clss_ls = list("SpecificResults","SpecificParameters") %>% list()),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Predictors",
slots_ls = list("a_YouthvarsProfile",
"b_SpecificParameters",
"c_SpecificResults",
"paths_chr") %>% list(),
pt_ls = list("YouthvarsProfile",
"SpecificParameters",
"SpecificResults",
"character") %>% list(),
class_desc_chr = "Modelling project dataset, input parameters and predictor comparison results.",
parent_class_chr = "SpecificProject",
inc_clss_ls = list("SpecificResults","SpecificParameters") %>% list()),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Fixed",
slots_ls = list("a_YouthvarsProfile",
"b_SpecificParameters",
"c_SpecificResults",
"paths_chr") %>% list(),
pt_ls = list("YouthvarsProfile",
"SpecificParameters",
"SpecificResults",
"character") %>% list(),
class_desc_chr = "Modelling project dataset, input parameters and complete fixed models results.",
parent_class_chr = "SpecificProject",
inc_clss_ls = list("SpecificResults","SpecificParameters") %>% list()),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Mixed",
slots_ls = list("a_YouthvarsProfile",
"b_SpecificParameters",
"c_SpecificResults",
"paths_chr") %>% list(),
pt_ls = list("YouthvarsProfile",
"SpecificParameters",
"SpecificResults",
"character") %>% list(),
class_desc_chr = "Modelling project dataset, input parameters and complete mixed models results.",
parent_class_chr = "SpecificProject",
inc_clss_ls = list("SpecificResults","SpecificParameters") %>% list()),
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Converter",
slots_ls = list("a_ScorzProfile") %>% list(),
pt_ls = list("ScorzProfile") %>% list(),
class_desc_chr = "Container for seed objects used for creating SpecificModels modules.",
parent_class_chr = "Ready4Module")
)
y <- y %>%
dplyr::bind_rows(y,
ready4class::make_pt_ready4class_constructor(make_s3_lgl = FALSE,
name_stub_chr = "Synopsis",
slots_ls = list("b_SpecificResults",
"c_SpecificParameters",
"d_YouthvarsProfile",
"e_Ready4useRepos") %>% list(),
pt_ls = list("SpecificResults",
"SpecificParameters",
"YouthvarsProfile",
"Ready4useRepos") %>% list(),
class_desc_chr = "Input, Output and Authorship Data For Generating Reports.",
parent_class_chr = "Ready4showSynopsis",
inc_clss_ls = list("SpecificResults","SpecificParameters") %>% list()))
y <- y %>%
dplyr::bind_rows(tibble::tribble(
~ make_s3_lgl, ~ name_stub_chr, ~ pt_ls, ~ pt_chkr_pfx_ls, ~ pt_ns_ls, ~ vals_ls, ~ allowed_vals_ls, ~ min_max_vals_ls, ~ start_end_vals_ls, ~ class_desc_chr, ~ parent_class_chr, ~ slots_ls, ~ meaningful_nms_ls, ~ inc_clss_ls, ~ asserts_ls,
TRUE, "predictors", list("tibble"), list("is_"), list("tibble"), list(short_name_chr = "character(0)",
long_name_chr = "character(0)",
min_val_dbl = "numeric(0)",
max_val_dbl = "numeric(0)",
class_chr = "character(0)",
increment_dbl = "numeric(0)",
class_fn_chr = "character(0)",
mdl_scaling_dbl = "numeric(0)",
covariate_lgl = "logical(0)"), NULL, NULL, NULL, "Candidate predictors lookup table", NA_character_, NULL, NULL, NULL, NULL,
TRUE, "models", list("tibble"), list("is_"), list("tibble"), list(short_name_chr = "character(0)",
long_name_chr = "character(0)",
control_chr = "character(0)",
family_chr = "character(0)",
fn_chr = "character(0)",
start_chr = "character(0)",
predn_type_chr = "character(0)",
tfmn_chr = "character(0)",
tfmn_for_bnml_lgl = "logical(0)",
fixed_acronym_chr = "character(0)",
mixed_acronym_chr = "character(0)",
mixed_type_chr = "character(0)",
with_chr = "character(0)"), NULL, NULL, NULL, "Candidate models lookup table", NA_character_, NULL, NULL, NULL, NULL)) %>%
ready4class::ready4class_constructor()
datasets_ls <- list(tibble::tibble(short_name_chr = c("OLS_NTF",
"OLS_LOG",
"OLS_LOGIT",
"OLS_LOGLOG",
"OLS_CLL",
"GLM_GSN_LOG",
"GLM_BNL_LOG",
"GLM_BNL_LGT",
"GLM_BNL_CLL",
"BET_LOG",
"BET_LGT",
"BET_CLL"),
long_name_chr = c("Ordinary Least Squares (no transformation)",
"Ordinary Least Squares (log transformation)",
"Ordinary Least Squares (logit transformation)",
"Ordinary Least Squares (log log transformation)",
"Ordinary Least Squares (complementary log log transformation)",
"Generalised Linear Model with Gaussian distribution and log link",
"Generalised Linear Model with Binomial distribution and log link",
"Generalised Linear Model with Binomial distribution and logit link",
"Generalised Linear Model with Binomial distribution and complementary log log link",
"Beta Regression Model with Binomial distribution and log link",
"Beta Regression Model with Binomial distribution and logit link",
"Beta Regression Model with Binomial distribution and complementary log log link")) %>%
dplyr::mutate(control_chr = c(rep(NA_character_,9),rep("betareg::betareg.control",3)),
family_chr = c(rep(NA_character_,5),"gaussian(log)","quasibinomial(log)","quasibinomial(logit)","quasibinomial(cloglog)", rep(NA_character_,3)),
fn_chr = c(rep("lm",5),rep("glm",4),rep("betareg::betareg",3)),
start_chr = c(rep(NA_character_,5),
rep("-0.1,-0.1",4),
rep("-0.5,-0.1,3",3)),
predn_type_chr = c(rep(NA_character_,5),
rep("response",7)),
tfmn_chr = dplyr::case_when(startsWith(short_name_chr, "OLS_") ~ purrr::map_chr(short_name_chr, ~ {
idx_1L_int <- 1 + stringi::stri_locate_last_fixed(.x,"_")[1,1] %>% as.vector()
stringr::str_sub(.x, start = idx_1L_int)
}),
T ~ "NTF"),
tfmn_for_bnml_lgl = c(rep(F,6),rep(T,3),rep(F,3)),
fixed_acronym_chr = dplyr::case_when(startsWith(short_name_chr, "OLS_") ~ "OLS",
T ~ "GLM"),
mixed_acronym_chr = dplyr::case_when(startsWith(short_name_chr, "OLS_") ~ "LMM",
T ~ "GLMM"),
mixed_type_chr = dplyr::case_when(startsWith(short_name_chr, "OLS_") ~ "linear mixed model",
T ~ "generalised linear mixed model"),
with_chr = long_name_chr %>%
purrr::map_chr(~ifelse(startsWith(.x,"Ordinary Least Squares"),
stringr::str_remove(.x,"Ordinary Least Squares ") %>%
stringr::str_sub(start = 2, end = -2),
stringr::str_remove(.x,"Generalised Linear Model with ") %>%
stringr::str_remove("Beta Regression Model with ")))) %>%
ready4fun::make_pkg_ds_ls(db_1L_chr = "mdl_types_lup",
title_1L_chr = "Model types lookup table",
desc_1L_chr = "A lookup table of abbreviations to describe the different model types"),
tibble::tibble(short_name_chr = c("coefs","hetg",
"dnst","sctr_plt",
"sim_dnst","sim_sctr",
"cnstrd_dnst","cnstrd_sctr_plt",
"cnstrd_sim_dnst","cnstrd_sim_sctr"),
long_name_chr = c("population level effects",
"group level effects",
"comparative densities of observed data and predictions using mean model parameter values",
"comparative scatter plot of observed and predictions using mean model parameter values",
"comparative densities of observed data and predictions using sampled model parameter values",
"comparative scatter plot of observed and predictions using sampled model parameter values",
"comparative densities of observed data and predictions using mean model parameter values and transformation of out of range predictions to upper and lower bounds",
"comparative scatter plot of observed and predictions using mean model parameter values and transformation of out of range predictions to upper and lower bounds",
"comparative densities of observed data and predictions using sampled model parameter values and transformation of out of range predictions to upper and lower bounds",
"comparative scatter plot of observed and predictions using sampled model parameter values and transformation of out of range predictions to upper and lower bounds")) %>%
ready4fun::make_pkg_ds_ls(db_1L_chr = "plt_types_lup",
title_1L_chr = "Model plot types lookup table",
desc_1L_chr = "A lookup table of abbreviations to describe different model plot types"),
# ADD TO PLOTS TABLE: # AUTOPLT # LNR_CMPRSN # PRED_DNSTY # PRED_SCTR # SIM_DNSTY # BORUTA_VAR_IMP # RF_VAR_IMP
tibble::tibble(rprt_nms_chr = "AAA_TTU_MDL_CTG",
title_chr = "Results supplement: longitudinal transfer to utility models.",
paths_to_rmd_dir_1L_chr = NA_character_,
pkg_dirs_chr = "Markdown",
packages_chr = "specific",
nms_of_rmd_chr = "Report_TS_Mdls.RMD",
rltv_paths_to_outp_yaml_chr = "_output.yml") %>%
tibble::add_case(rprt_nms_chr = "AAA_PMRY_ANLYS_MTH",
title_chr = "Methods supplement: Main analysis algorithm",
paths_to_rmd_dir_1L_chr = NA_character_,
pkg_dirs_chr = "Markdown",
packages_chr = "specific",
nms_of_rmd_chr = "Analyse.Rmd") %>%
tibble::add_case(rprt_nms_chr = "AAA_RPRT_WRTNG_MTH",
title_chr = "Methods supplement: algorithm to auto-generate reports.",
paths_to_rmd_dir_1L_chr = NA_character_,
pkg_dirs_chr = "Markdown",
packages_chr = "specific",
nms_of_rmd_chr = "Report.Rmd") %>%
ready4fun::make_pkg_ds_ls(db_1L_chr = "rprt_lup",
title_1L_chr = "Report types lookup table",
desc_1L_chr = "A lookup table of different report types"))
z <- ready4pack::make_pt_ready4pack_manifest(x,
constructor_r3 = y,
pkg_ds_ls_ls = datasets_ls) %>%
ready4pack::ready4pack_manifest()
z <- ready4::author(z)
ready4::write_extra_pkgs_to_actions(consent_1L_chr = "Y")
usethis::use_dev_package("cmdstanr",
type = "Suggests",
remote = "stan-dev/cmdstanr")
usethis::use_package("rstan",
type = "Suggests")
usethis::use_package("betareg",
type = "Suggests")
usethis::use_dev_package("scorz",
type = "Imports",
remote = "ready4-dev/scorz")
write_to_edit_workflow("pkgdown.yaml", consent_1L_chr = "Y") # In other packages, run for "test-coverage.yaml" as well.
readLines("_pkgdown.yml") %>%
stringr::str_replace_all(" - text: Model", " - text: Framework & Model") %>%
writeLines(con = "_pkgdown.yml")
devtools::build_vignettes()
# usethis::use_dev_package("ready4",
# type = "Depends",
# remote = "ready4-dev/ready4")
# usethis::use_dev_package("youthvars",
# type = "Depends",
# remote = "ready4-dev/youthvars")
#
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.