Skip to content

Commit

Permalink
improve environment handling in update.gnm
Browse files Browse the repository at this point in the history
  • Loading branch information
hturner committed Aug 24, 2023
1 parent fb1a6b1 commit ad021fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ parameters, fixes #21.
* Remove class check in `residSVD()`, so it can be applied to model objects
that do not inherit from class `"lm"`.
* Improved handling of `"nonlin"` functions in formula: prioritise functions in gnm over other packages; handle namespacing with `::`.
* Enable `update.gnm` to be called within a function, fixes #11.

Changes in gnm 1.1-2
====================
Expand Down
2 changes: 1 addition & 1 deletion R/update.gnm.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ update.gnm <- function (object, formula., ..., evaluate = TRUE)
}
}
if (evaluate)
eval(call, parent.frame())
eval(call, as.list(parent.frame()), environment(formula(object)))
else call
}

Binary file added tests/testthat/outputs/confint.rds
Binary file not shown.
13 changes: 13 additions & 0 deletions tests/testthat/test-confint.gnm.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
context("model spec [Symm]")

tol <- 1e-4

test_that("confint works within function call", {
# https://github.com/hturner/gnm/issues/11
f <- function(d) {
fit <- gnm(Freq ~ vote, family = poisson, data = d)
confint(fit)
}
expect_known_value(f(as.data.frame(cautres)),
file = test_path("outputs/confint.rds"))
})

0 comments on commit ad021fa

Please sign in to comment.