-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pairwise() and allow p-dimensional 'newmods' matrix.
- Loading branch information
Showing
149 changed files
with
1,113 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: metafor | ||
Version: 4.7-14 | ||
Date: 2024-06-07 | ||
Version: 4.7-15 | ||
Date: 2024-06-10 | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
pairwise <- function(x, btt, btt2, ...) { | ||
|
||
mstyle <- .get.mstyle() | ||
|
||
if (missing(x)) { | ||
x <- .getfromenv("pairwise", envir=.metafor) | ||
}# else { | ||
# if (is.atomic(x)) { | ||
# btt <- x | ||
# x <- .getfromenv("pairwise", envir=.metafor) | ||
# } | ||
#} | ||
|
||
if (is.null(x)) | ||
stop(mstyle$stop("Need to specify 'x' argument."), call.=FALSE) | ||
|
||
.chkclass(class(x), must="rma") | ||
|
||
if (x$int.only) | ||
stop(mstyle$stop("Cannot construct contrast matrices for intercept-only models.")) | ||
|
||
if (missing(btt) || is.null(btt)) | ||
stop(mstyle$stop("Need to specify 'btt' argument."), call.=FALSE) | ||
|
||
ddd <- list(...) | ||
|
||
.chkdots(ddd, c("fixed")) | ||
|
||
fixed <- .chkddd(ddd$fixed, FALSE, .isTRUE(ddd$fixed)) | ||
|
||
######################################################################### | ||
|
||
btt <- .set.btt(btt, x$p, x$int.incl, colnames(x$X), fixed=fixed) | ||
|
||
p <- length(btt) | ||
|
||
if (p == 1L) | ||
stop(mstyle$stop("Need to specify multiple coefficients via argument 'btt' for pairwise comparisons."), call.=FALSE) | ||
|
||
names <- rownames(x$beta) | ||
connames <- rep("", p*(p-1)/2) | ||
|
||
X <- matrix(0, nrow=p*(p-1)/2, ncol=x$p) | ||
row <- 0 | ||
|
||
for (i in 1:(p-1)) { | ||
btti <- btt[i] | ||
for (j in (i+1):p) { | ||
bttj <- btt[j] | ||
row <- row + 1 | ||
X[row,btti] <- -1 | ||
X[row,bttj] <- +1 | ||
connames[row] <- paste0(names[btti], "-", names[bttj]) | ||
} | ||
} | ||
|
||
rownames(X) <- connames | ||
|
||
######################################################################### | ||
|
||
### in case btt2 is specified, add these coefficients to X | ||
|
||
if (!missing(btt2)) { | ||
|
||
btt <- .set.btt(btt2, x$p, x$int.incl, colnames(x$X), fixed=fixed) | ||
|
||
p <- length(btt) | ||
|
||
Xadd <- matrix(0, nrow=p, ncol=x$p) | ||
|
||
for (i in 1:p) { | ||
Xadd[i,btt[i]] <- 1 | ||
} | ||
|
||
rownames(Xadd) <- names[btt] | ||
|
||
X <- rbind(Xadd, X) | ||
|
||
} | ||
|
||
######################################################################### | ||
|
||
return(X) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.