Skip to content

Commit

Permalink
add varying slopes check
Browse files Browse the repository at this point in the history
  • Loading branch information
s3alfisc committed Jul 8, 2023
1 parent 5adda88 commit 313211a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion R/boot_aggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ boot_aggregate <- function(
mm2 <- sparse_model_matrix(x, type = c("fixef")) |> as.matrix() |> as.data.frame()
mm <- cbind(X, mm2)
} else {

# varying slopes only allowed for objects of type "etwfe"
check_no_varying_slopes(x)
mm <- model.matrix(x)

}
Expand Down Expand Up @@ -433,5 +434,29 @@ boot_aggregate <- function(

}

check_no_varying_slopes <- function(object){

has_fixef <- "fixef_vars" %in% names(object)

if (
# '^' illegal in fixef argument, but legal in main formula -
# e.g. fml = y ~ x1 + I(x2^2) shold be possible
#' @srrstats {G2.4c} *explicit conversion to character via `as.character()`
#' (and not `paste` or `paste0`)* Done

(has_fixef &&
grepl("[",
Reduce(paste, as.character(as.formula(object$fml_all$fixef))),
fixed = TRUE) &&
!is.null(fe)
)
# note: whitespace ~ - for IV
# grepl("~", deparse_fml, fixed = TRUE)
) {
rlang::abort("Varying slopes fixed effects in `fixest::feols()` are currently not supported in boottest() when fe are projected out in the bootstrap via the `fe` function argument.")
}

}



0 comments on commit 313211a

Please sign in to comment.