Skip to content

Commit

Permalink
FIx get_statistic() for fixest::fenegbin()
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jan 1, 2025
1 parent da57301 commit a73b887
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: insight
Title: Easy Access to Model Information for Various Model Objects
Version: 1.0.0.3
Version: 1.0.0.4
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* Fixed issues in `find_predictors()` and `has_intercept()` for *brms* models
with `0 + Intercept` formula notation.

* Fixed issues in `get_statistic()` for models of class `fixest` from
negative-binomial families.

# insight 1.0.0

## Breaking changes
Expand Down
9 changes: 9 additions & 0 deletions R/get_statistic.R
Original file line number Diff line number Diff line change
Expand Up @@ -2199,6 +2199,15 @@ get_statistic.fixest <- function(x, ...) {
cs <- summary(x)$coeftable
params <- get_parameters(x)

# remove .theta row
rn <- rownames(cs)
if (!is.null(rn)) {
theta_row <- which(rn == ".theta")
if (length(theta_row)) {
cs <- cs[-theta_row, ]
}
}

out <- data.frame(
Parameter = params$Parameter,
Statistic = as.vector(cs[, 3]),
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-fixest.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ test_that("get_statistic", {
stat <- get_statistic(m3)
out <- as.data.frame(summary(m3)$coeftable)
expect_equal(stat$Statistic, out[, "z value"], tolerance = 1e-3, ignore_attr = TRUE)

skip_if_not_installed("glmmTMB")
data(Salamanders, package = "glmmTMB")
mod <- fixest::fenegbin(count ~ mined, data=Salamanders)

Check warning on line 290 in tests/testthat/test-fixest.R

View workflow job for this annotation

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

file=tests/testthat/test-fixest.R,line=290,col=46,[infix_spaces_linter] Put spaces around all infix operators.
out <- get_statistic(mod)
expect_equal(
out$Statistic,
summary(mod)$coeftable[1:2, 3],
ignore_attr = TRUE,
tolerance = 1e-4
)
})

test_that("get_predicted", {
Expand Down

0 comments on commit a73b887

Please sign in to comment.