Skip to content

Commit

Permalink
Merge pull request #62 from Lifebrain/grid
Browse files Browse the repository at this point in the history
Grid
  • Loading branch information
osorensen authored Jul 2, 2024
2 parents 37d9f75 + 6fcb157 commit 11ec358
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: metagam
Type: Package
Title: Meta-Analysis of Generalized Additive Models
Version: 0.4.0
Version: 0.4.0.9000
Authors@R: c(person("Oystein", "Sorensen",
email = "[email protected]",
role = c("aut", "cre"),
Expand Down Expand Up @@ -31,7 +31,7 @@ Imports:
ggplot2,
metafor,
rlang
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Suggests:
roxygen2,
knitr,
Expand Down
2 changes: 0 additions & 2 deletions R/metagam_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@
#'
#' @importFrom rlang .data
NULL


6 changes: 6 additions & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ extract_model_fits <- function(model, term_list, grid, type){
Map(function(term, xvar){
newdat <- create_newdat(xvar = xvar, grid = grid, type = type)

missing_vars <- setdiff(names(model$var.summary), colnames(newdat))
for(mv in missing_vars) {
eval(parse(text = paste0("newdat$", mv, "<- rep(model$var.summary[['",
mv, "']][[1]], nrow(newdat))")))
}

pred <- stats::predict(model, newdata = newdat, type = type,
se.fit = TRUE, terms = term)

Expand Down
5 changes: 4 additions & 1 deletion R/plot_metagam.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ plot.metagam <- function(x, term = NULL, ci = "none", legend = FALSE,
metadat <- x$meta_models$predictions
}


xvars <- x$term_list[[term]]$xvars
metadat <- metadat[, c(xvars, "estimate", "se")]

Expand All @@ -63,6 +62,10 @@ plot.metagam <- function(x, term = NULL, ci = "none", legend = FALSE,
ret$model <- nms[[ind]]
ret
})

common_cols <- Reduce(intersect, lapply(dat, colnames))
dat <- lapply(dat, function(df) df[, common_cols, drop = FALSE])

dat <- do.call(rbind, dat)
dat <- dat[, c(xvars, "fit", "se.fit", "model")]

Expand Down
19 changes: 19 additions & 0 deletions man/metagam-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions news.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# metagam (development versions)

- Added a workaround which allows not providing the unused variables when the
terms argument is used.

# metagam version 0.4.0

- Added a `meta_only` option to `plot.metagam()`.
Expand Down

0 comments on commit 11ec358

Please sign in to comment.