Skip to content

Commit

Permalink
resolve all remaining notes
Browse files Browse the repository at this point in the history
  • Loading branch information
qinyun-lin committed Apr 14, 2024
1 parent 6a96db4 commit daacc84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ importFrom(stats,chisq.test)
importFrom(stats,cor)
importFrom(stats,fisher.test)
importFrom(stats,glm)
importFrom(stats,pt)
importFrom(stats,qt)
importFrom(stats,var)
importFrom(tidyr,gather)
importFrom(utils,globalVariables)
3 changes: 2 additions & 1 deletion R/konfound-lm.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' @return The results of the konfound analysis for the specified variable(s).
#' @importFrom broom tidy glance
#' @importFrom dplyr select filter bind_cols
#' @importFrom stats var
konfound_lm <- function(model_object,
tested_variable_string,
alpha,
Expand All @@ -26,7 +27,7 @@ konfound_lm <- function(model_object,
glance_output <- broom::glance(model_object)

coef_df <- tidy_output[tidy_output$term == tested_variable_string, ]
sdx = unname(sqrt(diag(var(model_object$model)))[tested_variable_string])
sdx = unname(sqrt(diag(stats::var(model_object$model)))[tested_variable_string])

est_eff <- coef_df$estimate
std_err <- coef_df$std.error
Expand Down
5 changes: 3 additions & 2 deletions R/test_sensitivity_ln.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Main function to test sensitivity for non-linear models to be wrapped
# with pkonfound(), konfound(), and mkonfound()

#' @importFrom stats pt
test_sensitivity_ln <- function(est_eff,
std_err,
n_obs,
Expand Down Expand Up @@ -315,8 +316,8 @@ test_sensitivity_ln <- function(est_eff,

### Add to calculate p-value
if (tails == 2) {
p_start <- 2 * pt(abs(final_solution$t_start), n_obs - n_covariates - 2, lower.tail = FALSE)
p_final <- 2 * pt(abs(final_solution$t_final), n_obs - n_covariates - 2, lower.tail = FALSE)
p_start <- 2 * stats::pt(abs(final_solution$t_start), n_obs - n_covariates - 2, lower.tail = FALSE)
p_final <- 2 * stats::pt(abs(final_solution$t_final), n_obs - n_covariates - 2, lower.tail = FALSE)
} else if (tails == 1) {
p_start = pt(abs(final_solution$t_start), n_obs - n_covariates - 2, lower.tail = FALSE)
p_final = pt(abs(final_solution$t_final), n_obs - n_covariates - 2, lower.tail = FALSE)
Expand Down

0 comments on commit daacc84

Please sign in to comment.