diff --git a/R/factorial_designer.R b/R/factorial_designer.R index ae9ef4ee..8cda096e 100644 --- a/R/factorial_designer.R +++ b/R/factorial_designer.R @@ -99,6 +99,8 @@ factorial_designer <- function( if(k < 2 || !is_integerish(k)) stop("`k' should be a positive integer > 1.") if(any(outcome_sds<0)) stop("`outcome_sds' should be nonnegative.") if(any(assignment_probs <= 0)) stop("`assignment_probs' should have positive values only.") + if(!is.null(sd) && !is.null(outcome_sds) && !identical(outcome_sds, rep(sd, 2^k))) + warning("Both `sd` and `outcome_sd` are specified and have different values. Taking value of `outcome_sds`.") # pre-objects ------------------------------------------------------------- diff --git a/R/two_by_two_designer.R b/R/two_by_two_designer.R index 105b0522..12033f1f 100644 --- a/R/two_by_two_designer.R +++ b/R/two_by_two_designer.R @@ -78,6 +78,8 @@ two_by_two_designer <- function(N = 100, if(max(c(sd_i, outcome_sds) < 0) ) stop("sd_i and outcome_sds must be nonnegative") if(max(c(prob_A, prob_B) < 0)) stop("prob_ arguments must be nonnegative") if(max(c(prob_A, prob_B) > 1)) stop("prob_ arguments must not exceed 1") + if(!is.null(outcome_means) && all(!is.null(c(mean_A0B0, mean_A0B1, mean_A1B0, mean_A1B1))) && + !identical(outcome_means, c(mean_A0B0, mean_A0B1, mean_A1B0, mean_A1B1))) stop("Both `outcome_means` and `mean_*` parameters are specified and have different values. Taking value of `mean_*` arguments.") {{{ # M: Model diff --git a/tests/testthat/test_designers.R b/tests/testthat/test_designers.R index c5d486cd..b56b1e15 100644 --- a/tests/testthat/test_designers.R +++ b/tests/testthat/test_designers.R @@ -249,7 +249,7 @@ test_that(desc = "two_arm_covariate_designer errors when it should", expect_error(two_arm_covariate_designer(rho_WZ = 10)) }) -test_that(desc = "factorial_designer errors when it should", +test_that(desc = "factorial_designer errors or warns when it should", code = { expect_error(factorial_designer(outcome_name = c("Y "))) expect_error(factorial_designer(outcome_means = 1, k = 2)) @@ -260,6 +260,7 @@ test_that(desc = "factorial_designer errors when it should", expect_error(factorial_designer(k = .5)) expect_error(factorial_designer(outcome_sds = c(-1,-1,-1,-1), k = 2)) expect_error(factorial_designer(assignment_probs = c(-.5,.5), k = 2)) + expect_warning(factorial_designer(k = 2, sd = 1, outcome_sds = rep(.5, 4))) }) test_that(desc = "process_tracing_designer errors when it should",