Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Rename functions, scripts, pkgdown summary #35

Merged
merged 22 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
16cc773
DOC: #33 Dummy commit, opening PR for #33
shamindras Jan 24, 2021
4e6793e
DOC: #33 update the keywords as discussed with Riccardo Fogliato
shamindras Jan 25, 2021
55e0eab
DOC: #33 Change specific functions to be private
shamindras Jan 25, 2021
0d0ec06
DOC: #33 Change checkargs function name
shamindras Jan 25, 2021
1885458
DOC: #33 Fix checkargs function name yaml
shamindras Jan 25, 2021
f5e9e59
DOC: #33 Update naming yaml with hierarchy in comments, set vignette …
shamindras Jan 26, 2021
a108982
DOC: #33 Fix tests for gen_multiplier_bootstrap_weights, correct yaml
shamindras Jan 26, 2021
24e35d9
DOC: #33 Rebuild docs to fix tests
shamindras Jan 26, 2021
39484c3
DOC: #33 Fix reference to gen_multiplier_bootstrap_weights in utils
shamindras Jan 26, 2021
4264be7
DOC: #33 Try again to Fix reference to gen_multiplier_bootstrap_weights
shamindras Jan 26, 2021
3d81a32
DOC: #33 Try again with devtools::load_all()
shamindras Jan 26, 2021
b2ea143
DOC: #33 Try again with explit source
shamindras Jan 26, 2021
d5a3fa5
DOC: #33 Try again by changing location of source
shamindras Jan 26, 2021
f1e4e04
DOC: #33 Try again by changing location of source
shamindras Jan 26, 2021
11e0374
DOC: #33 Try again by copying in utils in multiplier boot tests
shamindras Jan 26, 2021
7c8c262
DOC: #33 Clean up unused utils in tests dir
shamindras Jan 26, 2021
8b9d686
DOC: #33 Clean up unused utils in tests dir final
shamindras Jan 26, 2021
355929f
Update replace-keywords.yaml
ricfog Jan 26, 2021
ef11332
Update replace-keywords.yaml
ricfog Jan 26, 2021
5e972a5
Update documentation of checkargs function
ricfog Jan 26, 2021
57c0e55
DOC: #33 Update and refresh documentation
shamindras Jan 26, 2021
2930f60
DOC: #33 rename files based on functionality
shamindras Jan 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,14 @@ export(as_name)
export(comp_boot_res)
export(comp_bootstrap_summary)
export(comp_coef_rwgt)
export(comp_coef_rwgt_single)
export(comp_cond_model)
export(comp_conf_int_bootstrap)
export(comp_empirical_bootstrap)
export(comp_empirical_bootstrap_samples)
export(comp_grid_centers)
export(comp_multiplier_bootstrap_var)
export(comp_multiplier_single_bootstrap_var)
export(comp_sandwich_qr_var)
export(enquo)
export(enquos)
export(expr)
export(focal_rwgt_var)
export(focal_slope)
export(gen_multiplier_bootstrap_weights)
export(nonlinearity_detection)
export(qqnorm_bootstrap)
export(set_ggplot2_theme)
export(sym)
export(syms)
importFrom(Rdpack,reprompt)
Expand Down
6 changes: 3 additions & 3 deletions R/boot-empirical-var.R → R/boot-empirical.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @return A tibble containing the bootstrap samples (\code{data})
#' and their corresponding number (\code{b}).
#'
#' @export
#' @keywords internal
#'
#' @importFrom rlang .data
#'
Expand Down Expand Up @@ -74,7 +74,7 @@ comp_empirical_bootstrap_samples <- function(data,
#' @return A tibble containing the estimated coefficients (\code{term}) of
#' the regressors (\code{term}).
#'
#' @export
#' @keywords internal
#'
#' @importFrom rlang .data
#'
Expand Down Expand Up @@ -164,7 +164,7 @@ comp_cond_model <- function(mod_fit, data, weights = NULL) {
#' bootstrapped dataset (\code{m}), the size of the original dataset
#' (\code{n}), and the number of the bootstrap repetition (\code{b}).
#'
#' @export
#' @keywords internal
#'
#' @importFrom rlang .data
#'
Expand Down
13 changes: 6 additions & 7 deletions R/model-diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#'
#' @return A vector of values corresponding to the centers for the reweighting.
#'
#' @export
#'
#' @keywords internal
#'
#' @importFrom rlang .data
#'
Expand Down Expand Up @@ -85,7 +84,7 @@ comp_grid_centers <- function(x, grid_method, n_grid) {
#' and estimates of the regression coefficients (\code{term} and
#' \code{estimate}).
#'
#' @export
#' @keywords internal
#'
#' @importFrom rlang .data
#'
Expand All @@ -99,7 +98,7 @@ comp_grid_centers <- function(x, grid_method, n_grid) {
#' y <- 2 + X1 + X2 * 0.3 + stats::rnorm(n, 0, 1)
#' df <- tibble::tibble(y = y, X1 = X1, X2 = X2, n_obs = 1:length(X1))
#' mod_fit <- stats::lm(y ~ X1 + X2, df)
#' boot_samples <- maars::comp_empirical_bootstrap_samples(df, B = 100)
#' boot_samples <- comp_empirical_bootstrap_samples(df, B = 100)
#' ols_rwgt_X1 <- comp_coef_rwgt_single(mod_fit, "X1", boot_samples, c(-1, 0, 1, 2))
#'
#' # Display the output
Expand All @@ -118,7 +117,7 @@ comp_coef_rwgt_single <- function(mod_fit, term_to_rwgt, boot_samples, term_to_r

out <- as.list(1:length(weights_assigned$center)) %>%
purrr::map_df(~ purrr::map(boot_samples$data,
~ maars::comp_cond_model(
~ comp_cond_model(
mod_fit = mod_fit,
data = .x %>% dplyr::mutate(weights = weights_assigned$weights[[.y]][n_obs]) %>%
dplyr::mutate(weights = weights / sum(weights)),
Expand Down Expand Up @@ -235,7 +234,7 @@ comp_coef_rwgt <- function(mod_fit,
m <- nrow(data)
}

boot_samples <- maars::comp_empirical_bootstrap_samples(
boot_samples <- comp_empirical_bootstrap_samples(
data = data %>% tibble::add_column(n_obs = 1:nrow(data)),
B = B,
m = m
Expand All @@ -252,7 +251,7 @@ comp_coef_rwgt <- function(mod_fit,
}

out <- terms_to_rwgt %>%
purrr::map(~ maars::comp_coef_rwgt_single(
purrr::map(~ comp_coef_rwgt_single(
mod_fit = mod_fit,
term_to_rwgt = .x[[1]],
boot_samples = boot_samples,
Expand Down
10 changes: 5 additions & 5 deletions R/ols-multiplier-boot-var.R → R/ols-boot-multiplier.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' @return A numeric vector of n (sampled with replacement) random multiplier
#' bootstrap weights based on the specified multiplier weights type.
#'
#' @export
#' @keywords internal
#'
#' @importFrom Rdpack reprompt
#' @importFrom rlang .data
Expand Down Expand Up @@ -110,7 +110,7 @@ gen_multiplier_bootstrap_weights <- function(n, weights_type) {
#'
#' @return A tibble of the bootstrap standard errors.
#'
#' @export
#' @keywords internal
#'
#' @importFrom rlang .data
#'
Expand Down Expand Up @@ -169,7 +169,7 @@ comp_multiplier_single_bootstrap_var <- function(n, J_inv_X_res, e) {
#'
#' @return A tibble of the bootstrap calculations.
#'
#' @export
#' @keywords internal
#'
#' @importFrom rlang .data
#'
Expand Down Expand Up @@ -204,8 +204,8 @@ comp_multiplier_bootstrap_var <- function(mod_fit, B, weights_type) {

# multiplier weights (mean 0, variance = 1)
e <- matrix(data =
maars::gen_multiplier_bootstrap_weights(n = B * n,
weights_type = weights_type),
gen_multiplier_bootstrap_weights(n = B * n,
weights_type = weights_type),
nrow = B,
ncol = n)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion R/ols-sandwich-var.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' @return A tibble containing the sandwich estimator of variance for OLS
#' regression.
#'
#' @export
#' @keywords internal
#'
#' @importFrom Rdpack reprompt
#' @importFrom rlang .data
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions R/scripts_and_filters/replace-keywords-orig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"comp_conf_int_bootstrap": "comp_mms_ci_boot"
"comp_coef_rwgt": "fit_reg_rwgt"
"focal_rwgt_var": "diag_mms_frwgt"
"focal_slope": "diag_mms_fslope"
"nonlinearity_detection": "diag_mms_nldetect"
"qqnorm_bootstrap": "diag_mms_boot_emp_qqn"
"get_ggplot2_theme": "set_mms_ggplot2_theme"
"comp_grid_centers": "comp_mms_grid_cent_rwgt"
"comp_sandwich_qr_var": "comp_mms_var_sand"
"comp_multiplier_bootstrap_var": "comp_mms_var_boot_mul"
"comp_multiplier_single_bootstrap_var": "comp_mms_var_boot_mul_ind"
"comp_coef_rwgt_single": "fit_reg_rwgt_ind"
"comp_empirical_bootstrap_samples": "comp_mms_boot_emp_smp"
"comp_empirical_bootstrap": "comp_mms_boot_emp"
"gen_multiplier_bootstrap_weights": "comp_mms_mul_boot_wgt"
"comp_cond_model": "fit_reg"
41 changes: 25 additions & 16 deletions R/scripts_and_filters/replace-keywords.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
comp_conf_int_bootstrap: "comp_mms_ci_boot"
comp_coef_rwgt: "fit_reg_rwgt"
focal_rwgt_var: "diag_mms_frwgt"
focal_slope: "diag_mms_fslope"
nonlinearity_detection: "diag_mms_nldetect"
qqnorm_bootstrap: "diag_mms_boot_emp_qqn"
set_ggplot2_theme: "set_mms_ggplot2_theme"
comp_grid_centers: "comp_mms_grid_cent_rwgt"
comp_sandwich_qr_var: "comp_mms_var_sand"
comp_multiplier_bootstrap_var: "comp_mms_var_boot_mul"
comp_multiplier_single_bootstrap_var: "comp_mms_var_boot_mul_ind"
comp_coef_rwgt_single: "fit_reg_rwgt_ind"
comp_empirical_bootstrap_samples: "comp_mms_boot_emp_smp"
comp_empirical_bootstrap: "comp_mms_boot_emp"
gen_multiplier_bootstrap_weights: "comp_mms_mul_boot_wgt"
comp_cond_model: "fit_reg"
# Statistical Utilities - Public Functions
"comp_conf_int_bootstrap": "comp_ci_boot"
"comp_coef_rwgt": "diag_fit_reg_rwgt"
"comp_bootstrap_summary": "comp_boot_summary"
# Statistical Utilities - Private Functions
"comp_sandwich_qr_var": "comp_sand_var"
"gen_multiplier_bootstrap_weights": "comp_boot_mul_wgt"
"comp_multiplier_single_bootstrap_var": "comp_boot_mul_ind"
"comp_multiplier_bootstrap_var": "comp_boot_mul"
"comp_cond_model": "fit_reg"
"comp_boot_res": "comp_boot_res"
"comp_empirical_bootstrap_samples": "gen_boot_emp_smp"
"comp_empirical_bootstrap": "comp_boot_emp"
"comp_grid_centers": "gen_grid_cent_rwgt"
"comp_coef_rwgt_single": "diag_fit_reg_rwgt_ind"
# Diagnostic Utilities - Public Functions
"focal_rwgt_var": "diag_foc_rwgt"
"focal_slope": "diag_foc_slope"
"qqnorm_bootstrap": "diag_boot_emp_qqn"
"nonlinearity_detection": "diag_nl_detect"
# Diagnostic Utilities - Private Functions
# Supporting Utilities - Public Functions
"get_ggplot2_theme": "set_ggplot2_theme"
# Supporting Utilities - Private Functions
"checkargs": "check_fn_args"
17 changes: 14 additions & 3 deletions R/utils-common.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' ("none", "left", "right", "bottom", "top", or two-element numeric vector)
#'
#' @return
#' @export
#' @keywords internal
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -54,8 +54,19 @@ set_ggplot2_theme <- function(ggplot_obj,
}




#' Check whether the arguments in the function are correctly specified
#'
#' \code{checkargs} is used to assess whether the arguments
#' are correctly specified and returns an error message if
#' they do not match the correct specification
#'
#' @param n Sample size.
#' @param B Bootstrap repetitions or number of bootstrap samples to be drawn.
#' @param m Number of observations to be sampled with replacement from the
#' dataset for each bootstrap repetition.
#'
#' @return
#' @keywords internal
checkargs <- function(n = NULL, B = NULL, m = NULL) {
if (!is.null(B)) {
assertthat::assert_that(B == as.integer(B),
Expand Down
4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading