Skip to content

Commit

Permalink
Added 'btt' (and 'att') argument to permutest().
Browse files Browse the repository at this point in the history
  • Loading branch information
wviechtb committed Jun 18, 2024
1 parent d1efe41 commit acc05b7
Show file tree
Hide file tree
Showing 133 changed files with 210 additions and 171 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: metafor
Version: 4.7-17
Date: 2024-06-12
Version: 4.7-18
Date: 2024-06-18
Title: Meta-Analysis Package for R
Authors@R: person(given = "Wolfgang", family = "Viechtbauer", role = c("aut","cre"), email = "wvb@metafor-project.org", comment = c(ORCID = "0000-0003-3463-4063"))
Depends: R (>= 4.0.0), methods, Matrix, metadat, numDeriv
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# metafor 4.7-17 (2024-06-12)
# metafor 4.7-18 (2024-06-18)

- the `predict.rma()` and `predict.rma.ls()` functions now also accept a matrix as input that includes a column for the intercept term (in which case the `intercept` argument is ignored)

Expand All @@ -22,6 +22,8 @@

- `fsn(..., type="General")` now computes the final estimates after rounding the fail-safe N value (not before)

- `permutest.rma.uni()` gains a `btt` argument and `permutest.rma.ls()` gains `btt` and `att` arguments

- added more tests

# metafor 4.6-0 (2024-03-28)
Expand Down
2 changes: 1 addition & 1 deletion R/misc.func.hidden.r
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

### make sure that at least one valid value is left
if (length(btt) == 0L)
stop(mstyle$stop("Non-existent coefficients specified via 'btt'."), call.=FALSE)
stop(mstyle$stop("Non-existent coefficient(s) specified via 'btt'."), call.=FALSE)

}

Expand Down
18 changes: 16 additions & 2 deletions R/permutest.rma.ls.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
permutest.rma.ls <- function(x, exact=FALSE, iter=1000, progbar=TRUE, digits, control, ...) {
permutest.rma.ls <- function(x, exact=FALSE, iter=1000, btt=x$btt, att=x$att, progbar=TRUE, digits, control, ...) {

mstyle <- .get.mstyle()

Expand All @@ -12,11 +12,13 @@ permutest.rma.ls <- function(x, exact=FALSE, iter=1000, progbar=TRUE, digits, co

ddd <- list(...)

.chkdots(ddd, c("tol", "time", "seed", "verbose", "permci", "skip.beta", "skip.alpha"))
.chkdots(ddd, c("tol", "time", "seed", "verbose", "permci", "skip.beta", "skip.alpha", "fixed"))

if (!is.null(ddd$tol)) # in case user specifies comptol in the old manner
comptol <- ddd$tol

fixed <- .chkddd(ddd$fixed, FALSE, .isTRUE(ddd$fixed))

if (.isTRUE(ddd$permci))
warning(mstyle$warning("Permutation-based CIs for location-scale models not currently available."), call.=FALSE)

Expand Down Expand Up @@ -71,6 +73,18 @@ permutest.rma.ls <- function(x, exact=FALSE, iter=1000, progbar=TRUE, digits, co
skip.alpha <- TRUE
}

if (!missing(btt) || !missing(att)) {

btt <- .set.btt(btt, x$p, x$int.incl, colnames(x$X), fixed=fixed)
att <- .set.btt(att, x$q, x$Z.int.incl, colnames(x$Z), fixed=fixed)

args <- list(yi=x$yi, vi=x$vi, weights=x$weights, mods=X, intercept=FALSE, scale=x$Z, link=x$link, method=x$method,
weighted=x$weighted, test=x$test, level=x$level, btt=btt, att=att, alpha=ifelse(x$alpha.fix, x$alpha, NA),
optbeta=x$optbeta, beta=ifelse(x$beta.fix, x$beta, NA), control=x$control)
x <- try(suppressWarnings(.do.call(rma.uni, args)), silent=!isTRUE(ddd$verbose))

}

#########################################################################
#########################################################################
#########################################################################
Expand Down
16 changes: 14 additions & 2 deletions R/permutest.rma.uni.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
permutest.rma.uni <- function(x, exact=FALSE, iter=1000, permci=FALSE, progbar=TRUE, digits, control, ...) {
permutest.rma.uni <- function(x, exact=FALSE, iter=1000, btt=x$btt, permci=FALSE, progbar=TRUE, digits, control, ...) {

mstyle <- .get.mstyle()

Expand All @@ -12,11 +12,13 @@ permutest.rma.uni <- function(x, exact=FALSE, iter=1000, permci=FALSE, progbar=T

ddd <- list(...)

.chkdots(ddd, c("tol", "time", "seed", "verbose"))
.chkdots(ddd, c("tol", "time", "seed", "verbose", "fixed"))

if (!is.null(ddd$tol)) # in case user specifies comptol in the old manner
comptol <- ddd$tol

fixed <- .chkddd(ddd$fixed, FALSE, .isTRUE(ddd$fixed))

iter <- round(iter)

if (iter <= 1)
Expand All @@ -25,6 +27,16 @@ permutest.rma.uni <- function(x, exact=FALSE, iter=1000, permci=FALSE, progbar=T
if (.isTRUE(ddd$time))
time.start <- proc.time()

if (!missing(btt)) {

btt <- .set.btt(btt, x$p, x$int.incl, colnames(x$X), fixed=fixed)

args <- list(yi=x$yi, vi=x$vi, weights=x$weights, mods=x$X, intercept=FALSE, method=x$method, weighted=x$weighted,
test=x$test, level=x$level, btt=btt, tau2=ifelse(x$tau2.fix, x$tau2, NA), control=x$control, skipr2=TRUE)
x <- try(suppressWarnings(.do.call(rma.uni, args)), silent=!isTRUE(ddd$verbose))

}

#########################################################################
#########################################################################
#########################################################################
Expand Down
4 changes: 2 additions & 2 deletions R/predict.rma.ls.r
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ level, digits, transf, targs, vcov=FALSE, ...) {
### but user can also decide to remove the intercept from the predictions with intercept=FALSE
### one special case: when the location model is an intercept-only model, one can set newmods=1 to obtain the predicted intercept

if (inherits(newmods, "matrix") && ncol(newmods) == x$p) {
if (!singlemod && ncol(X.new) == x$p) {

if (int.spec)
warning(mstyle$warning("Arguments 'intercept' ignored when 'newmods' includes 'p' columns."), call.=FALSE)
Expand Down Expand Up @@ -227,7 +227,7 @@ level, digits, transf, targs, vcov=FALSE, ...) {
### one special case: when the scale model is an intercept-only model, one can set newscale=1 to obtain the predicted intercept
### (which can be converted to tau^2 with transf=exp when using a log link)

if (inherits(newscale, "matrix") && ncol(newscale) == x$q) {
if (!singlescale && ncol(Z.new) == x$q) {

if (int.spec)
warning(mstyle$warning("Arguments 'intercept' ignored when 'newscale' includes 'q' columns."), call.=FALSE)
Expand Down
2 changes: 1 addition & 1 deletion R/predict.rma.r
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ level, digits, transf, targs, vcov=FALSE, ...) {
### but user can also decide to remove the intercept from the predictions with intercept=FALSE (but only do this when
### newmods was not a matrix with p columns)

if (inherits(newmods, "matrix") && ncol(newmods) == x$p) {
if (!singlemod && ncol(X.new) == x$p) {

if (int.spec)
warning(mstyle$warning("Arguments 'intercept' ignored when 'newmods' includes 'p' columns."), call.=FALSE)
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.onAttach <- function(libname, pkgname) {

ver <- "4.7-17"
ver <- "4.7-18"

loadmsg <- paste0("\nLoading the 'metafor' package (version ", ver, "). For an\nintroduction to the package please type: help(metafor)\n")

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metafor: A Meta-Analysis Package for R
[![R build status](https://github.com/wviechtb/metafor/workflows/R-CMD-check/badge.svg)](https://github.com/wviechtb/metafor/actions)
[![Code Coverage](https://codecov.io/gh/wviechtb/metafor/branch/master/graph/badge.svg)](https://app.codecov.io/gh/wviechtb/metafor)
[![CRAN Version](https://www.r-pkg.org/badges/version/metafor)](https://cran.r-project.org/package=metafor)
[![devel Version](https://img.shields.io/badge/devel-4.7--17-brightgreen.svg)](https://www.metafor-project.org/doku.php/installation#development_version)
[![devel Version](https://img.shields.io/badge/devel-4.7--18-brightgreen.svg)](https://www.metafor-project.org/doku.php/installation#development_version)
[![Monthly Downloads](https://cranlogs.r-pkg.org/badges/metafor)](https://cranlogs.r-pkg.org/badges/metafor)
[![Total Downloads](https://cranlogs.r-pkg.org/badges/grand-total/metafor)](https://cranlogs.r-pkg.org/badges/grand-total/metafor)

Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

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

2 changes: 1 addition & 1 deletion docs/ISSUE_TEMPLATE.html

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

2 changes: 1 addition & 1 deletion docs/articles/index.html

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

2 changes: 1 addition & 1 deletion docs/articles/pkgdown/diagram.html

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

2 changes: 1 addition & 1 deletion docs/authors.html

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

4 changes: 2 additions & 2 deletions docs/index.html

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

5 changes: 3 additions & 2 deletions docs/news/index.html

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

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pkgdown: 2.0.9
pkgdown_sha: ~
articles:
diagram: pkgdown/diagram.html
last_built: 2024-06-11T20:02Z
last_built: 2024-06-18T20:03Z
urls:
reference: https://wviechtb.github.io/metafor/reference
article: https://wviechtb.github.io/metafor/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/addpoly.default.html

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

2 changes: 1 addition & 1 deletion docs/reference/addpoly.html

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

2 changes: 1 addition & 1 deletion docs/reference/addpoly.predict.rma.html

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

2 changes: 1 addition & 1 deletion docs/reference/addpoly.rma.html

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

2 changes: 1 addition & 1 deletion docs/reference/aggregate.escalc.html

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

Loading

0 comments on commit acc05b7

Please sign in to comment.