Skip to content

Commit

Permalink
Added 'lim' argument to labbe().
Browse files Browse the repository at this point in the history
  • Loading branch information
wviechtb committed Apr 16, 2024
1 parent 0014f62 commit 191d2cb
Show file tree
Hide file tree
Showing 218 changed files with 297 additions and 248 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-4
Date: 2024-04-15
Version: 4.7-5
Date: 2024-04-16
Title: Meta-Analysis Package for R
Authors@R: person(given = "Wolfgang", family = "Viechtbauer", role = c("aut","cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-3463-4063"))
Depends: R (>= 4.0.0), methods, Matrix, metadat, numDeriv
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# metafor 4.7-4 (2024-04-15)
# metafor 4.7-5 (2024-04-16)

- made optimizers `Rcgmin` and `Rvmmin` available again via the `optimx` package

Expand Down
101 changes: 73 additions & 28 deletions R/labbe.rma.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
labbe.rma <- function(x, xlim, ylim, xlab, ylab,
labbe.rma <- function(x, xlim, ylim, lim, xlab, ylab,
add=x$add, to=x$to, transf, targs, pch=21, psize, plim=c(0.5,3.5), col, bg, grid=FALSE, lty, ...) {

mstyle <- .get.mstyle()
Expand All @@ -9,7 +9,7 @@ add=x$add, to=x$to, transf, targs, pch=21, psize, plim=c(0.5,3.5), col, bg, grid
stop(mstyle$stop("L'Abbe plots can only be drawn for models without moderators."))

if (!is.element(x$measure, c("RR","OR","RD","AS","IRR","IRD","IRSD")))
stop(mstyle$stop("Argument 'measure' must be set to one of the following: 'RR','OR','RD','AS','IRR','IRD','IRSD'."))
stop(mstyle$stop("Argument 'measure' must have been set to one of the following: 'RR','OR','RD','AS','IRR','IRD','IRSD'."))

na.act <- getOption("na.action")
on.exit(options(na.action=na.act), add=TRUE)
Expand Down Expand Up @@ -65,6 +65,14 @@ add=x$add, to=x$to, transf, targs, pch=21, psize, plim=c(0.5,3.5), col, bg, grid
grid <- TRUE
}

llim <- ddd$llim

lplot <- function(..., addyi, addvi, llim) plot(...)
lbox <- function(..., addyi, addvi, llim) box(...)
lsegments <- function(..., addyi, addvi, llim) segments(...)
llines <- function(..., addyi, addvi, llim) lines(...)
lpoints <- function(..., addyi, addvi, llim) points(...)

#########################################################################

### note: pch, psize, col, and bg (if vectors) must be of the same length as the original dataset
Expand Down Expand Up @@ -175,7 +183,7 @@ add=x$add, to=x$to, transf, targs, pch=21, psize, plim=c(0.5,3.5), col, bg, grid
}

if (length(dat.t$yi)==0L || length(dat.c$yi)==0L)
stop(mstyle$stop("No information in object to compute arm-level outcomes."))
stop(mstyle$stop("No information in object to compute the arm-level outcomes."))

#########################################################################

Expand Down Expand Up @@ -218,27 +226,44 @@ add=x$add, to=x$to, transf, targs, pch=21, psize, plim=c(0.5,3.5), col, bg, grid
max.yi <- max(c(dat.t$yi, dat.c$yi))
rng.yi <- max.yi - min.yi

len <- 1000
len <- 10000

intrcpt <- x$beta[1]

if (x$measure == "RD")
c.vals <- seq(ifelse(intrcpt>0, 0, -intrcpt), ifelse(intrcpt>0, 1-intrcpt, 1), length.out=len)
if (x$measure == "RR")
c.vals <- seq(min.yi-rng.yi, ifelse(intrcpt>0, 0-intrcpt, 0), length.out=len)
if (x$measure == "OR")
c.vals <- seq(min.yi-rng.yi, max.yi+rng.yi, length.out=len)
if (x$measure == "AS")
c.vals <- seq(ifelse(intrcpt>0, 0, -intrcpt), ifelse(intrcpt>0, asin(sqrt(1))-intrcpt, asin(sqrt(1))), length.out=len)
if (x$measure == "IRR")
c.vals <- seq(min.yi-rng.yi, ifelse(intrcpt>0, 0-intrcpt, 0), length.out=len)
if (x$measure == "IRD")
c.vals <- seq(ifelse(intrcpt>0, 0, -intrcpt), ifelse(intrcpt>0, 1-intrcpt, 1), length.out=len)
if (x$measure == "IRSD")
c.vals <- seq(ifelse(intrcpt>0, 0, -intrcpt), ifelse(intrcpt>0, 1-intrcpt, 1), length.out=len)
if (is.null(llim)) {

if (x$measure == "RD")
c.vals <- seq(ifelse(intrcpt>0, 0, -intrcpt), ifelse(intrcpt>0, 1-intrcpt, 1), length.out=len)
if (x$measure == "RR")
c.vals <- seq(min.yi-rng.yi, ifelse(intrcpt>0, -intrcpt, 0), length.out=len)
if (x$measure == "OR")
c.vals <- seq(min.yi-rng.yi, max.yi+rng.yi, length.out=len)
if (x$measure == "AS")
c.vals <- seq(ifelse(intrcpt>0, 0, -intrcpt), ifelse(intrcpt>0, asin(sqrt(1))-intrcpt, asin(sqrt(1))), length.out=len)
if (x$measure == "IRR")
c.vals <- seq(min.yi-rng.yi, ifelse(intrcpt>0, -intrcpt, 0), length.out=len)
if (x$measure == "IRD")
c.vals <- seq(ifelse(intrcpt>0, 0, -intrcpt), ifelse(intrcpt>0, 1-intrcpt, 1), length.out=len)
if (x$measure == "IRSD")
c.vals <- seq(ifelse(intrcpt>0, 0, -intrcpt), ifelse(intrcpt>0, 1-intrcpt, 1), length.out=len)

} else {

if (length(llim) != 2L)
stop(mstyle$stop("Argument 'llim' must be of length 2."))

c.vals <- seq(llim[1], llim[2], length.out=len)

}

t.vals <- intrcpt + 1*c.vals

if (!is.null(llim)) {
sel.c <- c.vals >= llim[1] & c.vals <= llim[2]
sel.ct <- t.vals >= llim[1] & c.vals >= llim[1] & t.vals <= llim[2] & c.vals <= llim[2]
c.vals <- c.vals[sel.c]
}

if (is.function(transf)) {
if (is.null(targs)) {
dat.t$yi <- sapply(dat.t$yi, transf)
Expand All @@ -253,14 +278,25 @@ add=x$add, to=x$to, transf, targs, pch=21, psize, plim=c(0.5,3.5), col, bg, grid
}
}

#print(round(cbind(c.vals, t.vals), 3))

min.yi <- min(c(dat.t$yi, dat.c$yi))
max.yi <- max(c(dat.t$yi, dat.c$yi))

if (missing(xlim))
xlim <- c(min.yi, max.yi)
if (missing(lim)) {

if (missing(ylim))
ylim <- c(min.yi, max.yi)
if (missing(xlim))
xlim <- c(min.yi, max.yi)

if (missing(ylim))
ylim <- c(min.yi, max.yi)

} else {

xlim <- lim
ylim <- lim

}

### order points by psize

Expand All @@ -287,23 +323,32 @@ add=x$add, to=x$to, transf, targs, pch=21, psize, plim=c(0.5,3.5), col, bg, grid
ylab <- paste(ylab, "(Group 2)")
}

plot(NA, NA, xlim=xlim, ylim=ylim, xlab=xlab, ylab=ylab, ...)
lplot(NA, NA, xlim=xlim, ylim=ylim, xlab=xlab, ylab=ylab, ...)

### add grid (and redraw box)

if (.isTRUE(grid)) {
grid(col=gridcol)
box(...)
lbox(...)
}

### add diagonal and estimated effects lines
### add diagonal reference line

#abline(a=0, b=1, lty=lty[1], ...)
lsegments(min(c.vals), min(c.vals), max(c.vals), max(c.vals), lty=lty[1], ...)

### add estimated effects line

if (!is.null(llim)) {
c.vals <- c.vals[sel.ct]
t.vals <- t.vals[sel.ct]
}

abline(a=0, b=1, lty=lty[1], ...)
lines(c.vals, t.vals, lty=lty[2], ...)
llines(c.vals, t.vals, lty=lty[2], ...)

### add points

points(x=dat.c$yi.o, y=dat.t$yi.o, cex=psize.o, pch=pch.o, col=col.o, bg=bg.o, ...)
lpoints(x=dat.c$yi.o, y=dat.t$yi.o, cex=psize.o, pch=pch.o, col=col.o, bg=bg.o, ...)

#########################################################################

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-4"
ver <- "4.7-5"

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--4-brightgreen.svg)](https://www.metafor-project.org/doku.php/installation#development_version)
[![devel Version](https://img.shields.io/badge/devel-4.7--5-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.

4 changes: 2 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.8
pkgdown_sha: ~
articles:
diagram: pkgdown/diagram.html
last_built: 2024-04-15T20:10Z
last_built: 2024-04-16T20:32Z
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.

2 changes: 1 addition & 1 deletion docs/reference/anova.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/baujat.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/bldiag.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/blsplit.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/blup.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/coef.permutest.rma.uni.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/coef.rma.html

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

Loading

0 comments on commit 191d2cb

Please sign in to comment.