Skip to content

Commit

Permalink
Wrong DFs in model_parameters.fixest
Browse files Browse the repository at this point in the history
Fixes #892
  • Loading branch information
strengejacke committed Sep 9, 2023
1 parent fa44f61 commit a131fca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions R/methods_fixest.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ model_parameters.fixest <- function(model,
...) {
# default ci-method, based on statistic
if (is.null(ci_method)) {
if (identical(insight::find_statistic(model), "t-statistic")) {
if (identical(insight::find_statistic(model), "t-statistic") && identical(model$method, "feols")) {
ci_method <- "residual"
} else {
ci_method <- "wald"
ci_method <- "normal"
}
}

Expand Down Expand Up @@ -92,8 +92,14 @@ degrees_of_freedom.fixest <- function(model, method = "wald", ...) {
}
method <- match.arg(
tolower(method),
choices = c("wald", "residual")
choices = c("wald", "residual", "normal")
)

# we may have Inf DF, too
if (method == "normal") {
return(Inf)
}

method <- switch(method,
"wald" = "t",

Check warning on line 104 in R/methods_fixest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/methods_fixest.R,line=104,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
"residual" = "resid"

Check warning on line 105 in R/methods_fixest.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/methods_fixest.R,line=105,col=5,[keyword_quote_linter] Only quote named arguments to functions if necessary, i.e., if the name is not a valid R symbol (see ?make.names).
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-model_parameters.fixest.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test_that("model_parameters.fixest", {
)
params <- model_parameters(m, verbose = FALSE)

expect_equal(c(nrow(params), ncol(params)), c(2, 9))
expect_identical(c(nrow(params), ncol(params)), c(2L, 9L))
expect_equal(params$p, as.vector(fixest::pvalue(m)), tolerance = 1e-3)
expect_equal(params$df_error[1], as.vector(fixest::degrees_freedom(m, type = "t")), tolerance = 1e-3)
expect_equal(params$Coefficient, as.vector(coef(m)), tolerance = 1e-3)
Expand Down

0 comments on commit a131fca

Please sign in to comment.