Skip to content

Commit

Permalink
Fix model_info.averaging
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 26, 2024
1 parent 49bf202 commit 7367140
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
4 changes: 3 additions & 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: 0.99.0.22
Version: 0.99.0.23
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -86,6 +86,7 @@ Suggests:
AER,
afex,
aod,
ape,
BayesFactor,
bayestestR,
bbmle,
Expand Down Expand Up @@ -175,6 +176,7 @@ Suggests:
parsnip,
pbkrtest,
performance,
phylolm,
plm,
poorman,
PROreg (>= 1.3.0),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
* Fixed edge case in `find_transformation()` for simple log-transformation of
the response variable.

* Fixed issue for `model_info.averaging()`.

# insight 0.20.5

## General
Expand Down
4 changes: 2 additions & 2 deletions R/model_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,10 @@ model_info.summary.lm <- model_info.Arima
#' @export
model_info.averaging <- function(x, ...) {
if (is.null(attributes(x)$modelList)) {
format_warning("Can't calculate covariance matrix. Please use 'fit = TRUE' in 'model.avg()'.")
format_warning("Can't access model information. Please use 'fit = TRUE' in 'model.avg()'.")
return(NULL)
}
model_info.default(x = attributes(x)$modelList[[1]])
model_info(x = attributes(x)$modelList[[1]])
}


Expand Down
38 changes: 38 additions & 0 deletions tests/testthat/test-phylolm.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
skip_if_not_installed("phylolm")
skip_if_not_installed("ape")
skip_on_cran()

test_that("MuMIn link functions", {
set.seed(123456)
tre = ape::rcoal(60)

Check warning on line 7 in tests/testthat/test-phylolm.R

View workflow job for this annotation

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

file=tests/testthat/test-phylolm.R,line=7,col=7,[assignment_linter] Use <-, not =, for assignment.
taxa = sort(tre$tip.label)

Check warning on line 8 in tests/testthat/test-phylolm.R

View workflow job for this annotation

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

file=tests/testthat/test-phylolm.R,line=8,col=8,[assignment_linter] Use <-, not =, for assignment.
b0 = 0

Check warning on line 9 in tests/testthat/test-phylolm.R

View workflow job for this annotation

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

file=tests/testthat/test-phylolm.R,line=9,col=6,[assignment_linter] Use <-, not =, for assignment.
b1 = 1

Check warning on line 10 in tests/testthat/test-phylolm.R

View workflow job for this annotation

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

file=tests/testthat/test-phylolm.R,line=10,col=6,[assignment_linter] Use <-, not =, for assignment.

x <- phylolm::rTrait(
n = 1,
phy = tre,
model = "BM",
parameters = list(ancestral.state = 0, sigma2 = 10)
)
y <- b0 + b1 * x +
phylolm::rTrait(
n = 1,
phy = tre,
model = "lambda",
parameters = list(
ancestral.state = 0,
sigma2 = 1,
lambda = 0.5
)
)
dat <- data.frame(trait = y[taxa], pred = x[taxa])
mod <- phylolm::phylolm(
trait ~ pred,
data = dat,
phy = tre,
model = "lambda"
)
out <- model_info(mod)
expect_true(out$is_linear)
})

0 comments on commit 7367140

Please sign in to comment.