diff --git a/R/checks.R b/R/checks.R index e8b5970..5f6f5c5 100644 --- a/R/checks.R +++ b/R/checks.R @@ -17,23 +17,24 @@ kernel_type <- function(kern) { process_options <- function(M, se.method, method, d, kern) { if (kernel_type(kern)=="optimal" && method!="SRD") stop("Optimal kernel requires sharp RD design.") + m_len <- if (method=="FRD") 2 else 1 if (!missing(M)) { - m_len <- if (method=="FRD") 2 else 1 if (!check_positive(M, m_len)) stop(paste0("M must be a non-negative numeric vector of length", m_len, ".")) } - if (min(sum(d$p), sum(d$m))==0) { + if (method=="IP") { + if (!is.null(d$covs)) + stop("Covariates not allowed whem method is 'IP'.") + } else if (min(sum(d$p), sum(d$m))==0) { stop("No observations on one side of the cutoff") } + if (!(se.method %in% c("nn", "EHW", "supplied.var"))) { stop("Unsupported se.method") } if (se.method=="nn" && !is.null(d$clusterid)) stop(paste0("'se.method=\"nn\"' not allowed with clustered standard", " errors.\nUse 'se.method=\"EHW\"'")) - - if (!is.null(d$covs) && method=="IP") - stop("Covariates not allowed whem method is 'IP'.") } diff --git a/doc/manual.pdf b/doc/manual.pdf index 02bea79..31cc9a0 100644 Binary files a/doc/manual.pdf and b/doc/manual.pdf differ diff --git a/tests/testthat/test_interface.R b/tests/testthat/test_interface.R index e745471..667230f 100644 --- a/tests/testthat/test_interface.R +++ b/tests/testthat/test_interface.R @@ -4,10 +4,8 @@ test_that("Test inputs", { expect_error(r2 <- RDHonest(log(cn)~elig_year, data=rcp, kern="Unif")) expect_error(RDHonest(log(cn)|retired~elig_year, data=rcp, M=1, T0=0, kern="optimal")) - expect_message(pp <- RDHonest(voteshare~margin, data=lee08, - M=2, h=5, subset=I(margin>0))$coefficients) - expect_equal(as.numeric(pp[c(2, 3, 11)]), - c(0L, sqrt(.Machine$double.xmax/10), NA)) + expect_error(pp <- RDHonest(voteshare~margin, data=lee08, + M=2, h=5, subset=I(margin>0))$coefficients) expect_error(RDHonest(c~elig_year, data=rcp, clusterid=seq_along(rr$c), point.inference=TRUE)) ## Insufficient unique values of the running variable to compute rule of