Skip to content

Commit cc34683

Browse files
Merge pull request #31 from JensBaalkilde/master
Version 2.7.3: Updates to drmHetVar, bmdHetVar bmdHetVarMA and general clean-up.
2 parents 304c2c5 + 01ce814 commit cc34683

72 files changed

Lines changed: 2267 additions & 761 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

2 KB
Binary file not shown.

.Rbuildignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
cache/
44
README.Rmd
55
README.md
6-
README_files/
6+
README_files/
7+
^\\.github$

.github/workflows/r.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
#
6+
# See https://github.com/r-lib/actions/tree/master/examples#readme for
7+
# additional example workflows available for the R community.
8+
19
on:
210
push:
311
branches: [main, master]
@@ -43,7 +51,6 @@ jobs:
4351
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('DESCRIPTION') }}
4452
restore-keys: |
4553
${{ runner.os }}-r-${{ matrix.config.r }}-
46-
4754
- name: Install dependencies
4855
run: |
4956
install.packages(c("sandwich", "CVXR", "multcomp", "gridExtra", "isotone",
@@ -68,4 +75,4 @@ jobs:
6875
uses: actions/upload-artifact@v4
6976
with:
7077
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
71-
path: check
78+
path: check

DESCRIPTION

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
Package: bmd
22
Type: Package
33
Title: Benchmark dose estimation for dose-response data
4-
Version: 2.7.1
4+
Version: 2.7.3
55
Date: 2025-03-24
66
Author: Signe M.Jensen, Christian Ritz and Jens Riis Baalkilde
77
Maintainer: Signe M. Jensen <smj@plen.ku.dk>
8-
Description: Benchmark dose analysis for continuous, quantal, count and ordinal dose-response data
9-
Imports:
10-
drc,
8+
Description: Provides tools for benchmark dose analysis of dose-response data. Supports continuous, quantal, count, and ordinal responses.
9+
Imports:
10+
drc,
1111
ggplot2,
12-
dplyr
12+
dplyr,
13+
stats
1314
Suggests:
1415
sandwich,
1516
CVXR,
1617
multcomp,
1718
gridExtra,
1819
isotone,
1920
reshape2,
20-
dplyr,
2121
car,
2222
Matrix,
23-
RLRsim,
2423
scales,
24+
metafor,
25+
tidyr,
26+
numDeriv,
2527
drcData,
2628
testthat (>= 3.0.0)
2729
Remotes:
28-
doseresponse/drcData,
29-
doseresponse/drc
30-
License: GPL
30+
doseresponse/drc,
31+
doseresponse/drcData
32+
License: file LICENSE
3133
Encoding: UTF-8
3234
LazyData: true
3335
Config/testthat/edition: 3
36+
RoxygenNote: 7.3.2
37+
Depends:
38+
R (>= 3.5)

NAMESPACE

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
import(drc, ggplot2, dplyr)
2+
importFrom("graphics", "lines")
3+
importFrom("stats", "aggregate", "approx", "as.formula", "coef",
4+
"complete.cases", "confint", "constrOptim", "df.residual",
5+
"dnorm", "fitted", "lm", "model.frame", "model.matrix",
6+
"optim", "pnorm", "predict", "qchisq", "qnorm", "qt",
7+
"quantile", "rbinom", "resid", "residuals", "rnorm", "sd",
8+
"uniroot", "update", "var", "vcov", "AIC", "BIC", "logLik")
9+
importFrom("utils", "setTxtProgressBar", "txtProgressBar")
210
export(bmd, bmdBoot, bmdIso, bmdIsoBoot, PAV, bmdMA, bootDataGen, bmdMACurve, BCa, invBmd, expandBinomial,
311
getStackingWeights, drmOrdinal, bmdOrdinal, bmdOrdinalMA,
4-
expandOrdinal, bootDataGenOrdinal,
5-
qplotDrc, qplotBmd, MACurve, monotonicityTest, trendTest, bmdHetVar, drmHetVar)
12+
qplotDrc, qplotBmd, MACurve, monotonicityTest, trendTest, bmdHetVar, drmHetVar, drmMMRE, bmdHetVarMA)
613

714
## S3 methods
815
S3method(logLik, drcOrdinal)
16+
S3method(logLik, drcHetVar)
917
S3method(AIC, drcOrdinal)
18+
S3method(AIC, drcHetVar)
1019
S3method(BIC, drcOrdinal)
20+
S3method(BIC, drcHetVar)
1121
S3method(plot, drcOrdinal)
1222
S3method(print, drcOrdinal)
1323
S3method(print, bmdOrdinal)
24+
S3method(print, drcHetVar)
1425
S3method(plot, bmd)
15-
S3method(plot, drcHetVar)
26+
S3method(plot, drcHetVar)
27+
S3method(vcov, drcMMRE)
28+
S3method(print, drcMMRE)
29+
S3method(coef, drcHetVar)

R/AIC.drcOrdinal.R

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
AIC.drcOrdinal <- function(object, epsilon = 10^(-16)){
1+
AIC.drcOrdinal <- function(object, ..., k = 2) {
2+
dots <- list(...)
3+
if (!is.null(dots$epsilon)){
4+
epsilon <- dots$epsilon
5+
} else {
6+
epsilon <- 1e-16
7+
}
8+
29
n.parameters <- sum(sapply(object$drmList, function(mod) length(mod$coefficients)))
3-
- 2 * logLik(object, epsilon) + 2 * n.parameters
4-
}
10+
-2 * logLik(object, epsilon = epsilon) + k * n.parameters
11+
}

R/BIC.drcOrdinal.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
BIC.drcOrdinal <- function(object, epsilon = 10^(-16)){
1+
BIC.drcOrdinal <- function(object, ...){
2+
dots <- list(...)
3+
if (!is.null(dots$epsilon)){
4+
epsilon <- dots$epsilon
5+
} else {
6+
epsilon <- 1e-16
7+
}
8+
29
n.parameters <- sum(sapply(object$drmList, function(mod) length(mod$coefficients)))
310
n.obs <- sum(object$data[[object$weights]])
411
n.parameters * log(n.obs) - 2 * logLik(object, epsilon)

R/PAV.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
PAV<-function(object,data,type){
1+
PAV<-function(formula,data,type){
2+
object <- formula
23
if( identical(type,"binomial")){
34
N <- length( data[, paste(object[[3]]) ])
45
Events <- data[, strsplit(as.character(object[[2]]),"/")[[2]] ]

R/bmd.R

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ bmd<-function(object, bmr, backgType = c("modelBased", "absolute", "hybridSD", "
1717
backgType <- "modelBased"
1818
}
1919
if (missing(backgType)) {
20-
stop(paste("backgType is missing", sep=""))
20+
if(!(def %in% c("hybridExc", "hybridAdd"))){
21+
backgType <- "modelBased"
22+
} else {
23+
backgType <- "hybridSD"
24+
}
2125
}
2226
if (!(def %in% c("excess", "additional", "relative", "extra", "added", "hybridExc", "hybridAdd", "point"))) {
2327
stop(paste("Could not recognize def", sep=""))
@@ -29,16 +33,19 @@ bmd<-function(object, bmr, backgType = c("modelBased", "absolute", "hybridSD", "
2933
level <- 1-2*(1-level)
3034

3135
interval <- match.arg(interval)
36+
if(inherits(object, "drcMMRE") & interval != "delta"){
37+
stop("only delta type confidence interval supported for object of type \"drcMMRE\"")
38+
}
3239
if(interval == "sandwich"){
3340
sandwich.vcov <- TRUE
3441
interval <- "delta"
3542
}
36-
if(sandwich.vcov & !require("sandwich")){
43+
if(sandwich.vcov & !requireNamespace("sandwich")){
3744
stop('package "sandwich" must be installed to compute sandwich confidence intervals')
3845
}
3946
respTrans <- match.arg(respTrans)
4047

41-
if(class(object$fct) == "braincousens" & is.null(object$fct$fixed)){
48+
if(inherits(object$fct, "braincousens") & is.null(object$fct$fixed)){
4249
if(object$fct$name == "BC.4"){
4350
object$fct$fixed <- c(NA, 0, NA, NA, NA)
4451
} else if(object$fct$name == "BC.5"){
@@ -82,8 +89,12 @@ bmd<-function(object, bmr, backgType = c("modelBased", "absolute", "hybridSD", "
8289
}
8390
dBmdVal <- EDeval[[2]] + bmrScaledList$dBmrScaled[,1] / fctDerivx(bmdVal, t(parmMat))[1]
8491
bmdSEVal <- sqrt(dBmdVal %*% varCov %*% dBmdVal)
85-
intMat <- drc:::confint.basic(matrix(c(bmdVal, bmdSEVal), ncol = 2),
86-
level = level, object$"type", df.residual(object), FALSE)
92+
if(inherits(object, "drcMMRE")){
93+
intMat <- matrix(qnorm(c((1-level)/2, 1-(1-level)/2), mean = bmdVal, sd = bmdSEVal), ncol = 2)
94+
} else {
95+
intMat <- drc:::confint.basic(matrix(c(bmdVal, bmdSEVal), ncol = 2),
96+
level = level, object$"type", df.residual(object), FALSE)
97+
}
8798
} else if(interval == "inv"){
8899
if(!identical(respTrans, "none")){stop("inverse regression interval not available for transformed response.")}
89100
slope <- drop(ifelse(object$curve[[1]](0)-object$curve[[1]](Inf)>0,"decreasing","increasing"))

R/bmdBoot.R

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bmdBoot <- function(object, bmr, R=1000, bootType="nonparametric", bmdType = "or
3838

3939
respTrans <- match.arg(respTrans)
4040

41-
if(class(object$fct) == "braincousens" & is.null(object$fct$fixed)){
41+
if(inherits(object$fct, "braincousens") & is.null(object$fct$fixed)){
4242
if(object$fct$name == "BC.4"){
4343
object$fct$fixed <- c(NA, 0, NA, NA, NA)
4444
} else if(object$fct$name == "BC.5"){
@@ -57,16 +57,17 @@ bmdBoot <- function(object, bmr, R=1000, bootType="nonparametric", bmdType = "or
5757
get.drm.list <- function(tmp.data){
5858
if(ncol(object$parmMat) == 1){
5959
drm.list.tmp <- lapply(tmp.data, function(x){
60-
try(eval(substitute(drm(formula0, data = x, type = object$type, fct = object[["fct"]]),
60+
try(eval(substitute(drm(formula0, data = x, type = object$type, fct = object[["fct"]],
61+
control = drmc(noMessage = TRUE)),
6162
list(formula0 = object$call$formula)
6263
)), TRUE)
6364
}
6465
)
6566
} else if(is.null(object$call$pmodels)){
6667
drm.list.tmp <- lapply(tmp.data, function(x){
67-
if(object$type != "binomial"){
68-
x[[as.character(object$call$curveid)]] <- x[[paste0("orig.", as.character(object$call$curveid))]]
69-
}
68+
# if(object$type != "binomial"){
69+
# x[[as.character(object$call$curveid)]] <- x[[paste0("orig.", as.character(object$call$curveid))]]
70+
# }
7071
try(
7172
eval(substitute(drm(object$call$formula, weights = weights0, curveid = curveid0,
7273
data = x, type = object$type, fct = object$fct, control = drmc(noMessage = TRUE)),
@@ -77,11 +78,11 @@ bmdBoot <- function(object, bmr, R=1000, bootType="nonparametric", bmdType = "or
7778
})
7879
} else {
7980
drm.list.tmp <- lapply(tmp.data, function(x){
80-
if(object$type != "binomial"){
81-
x[[as.character(object$call$curveid)]] <- x[[paste0("orig.", as.character(object$call$curveid))]]
82-
}
81+
# if(object$type != "binomial"){
82+
# x[[as.character(object$call$curveid)]] <- x[[paste0("orig.", as.character(object$call$curveid))]]
83+
# }
8384
try(
84-
eval(substitute(drm(formula0, weights = weights0, curveid = curveid0,pmodels = pmodels0,
85+
eval(substitute(drm(formula0, weights = weights0, curveid = curveid0, pmodels = pmodels0,
8586
data = x, type = object$type, fct = object$fct, control = drmc(noMessage = TRUE)),
8687
list(formula0 = object$call$formula,
8788
weights0 = object$call$weights,
@@ -138,7 +139,7 @@ bmdBoot <- function(object, bmr, R=1000, bootType="nonparametric", bmdType = "or
138139
if(identical(bootInterval,"BCa")){
139140
jackData <- list()
140141
for(i in 1:(dim(object$data)[1])){
141-
jackData[[i]] <- object$data[-i,]
142+
jackData[[i]] <- object$origData[-i,]
142143
}
143144
# bootJack.drm.tmp <- lapply(jackData, function(x){
144145
# try(drm(object$call$formula, data = x, fct = object[["fct"]]),TRUE)

0 commit comments

Comments
 (0)