0

I've followed the code provided in the vignette of crmPack (pages 16-17) to define the one-parameter power model. I would need to feed it some toxicity data using the update function, but the error I get is "no slot of name "call"". Here is the code below. I would be very grateful for any comments or ideas in order to "fix" this. Many thanks.

# package and options
library(crmPack)

options <- McmcOptions(burnin = 1000, step = 2, samples = 5000)

set.seed(1)

# extra functions to define the power model

.OneParExp <- setClass(Class = "OneParExp", contains = "Model",
 representation(skeletonFun = "function",
 skeletonProbs = "numeric",
 lambda = "numeric"))


OneParExp <- function(skeletonProbs, doseGrid, lambda)
 {
 skeletonFun <- approxfun(x = doseGrid, y = skeletonProbs, rule = 2)
 invSkeletonFun <- approxfun(x = skeletonProbs, y = doseGrid, rule = 1)

 .OneParExp(
 skeletonFun = skeletonFun, skeletonProbs = skeletonProbs,
 lambda = lambda,
 datamodel = function(){
 for (i in 1:nObs)
 {
 y[i] ~ dbern(p[i])
 p[i] <- skeletonProbs[xLevel[i]]^theta
 }},
 datanames = c("nObs", "y", "xLevel"),
 prob = function(dose, theta){ skeletonFun(dose)^theta },
 dose = function(prob, theta){ invSkeletonFun(prob^(1 / theta)) },
 priormodel = function(){ theta ~ dexp(lambda) },
 modelspecs = function(){ list(skeletonProbs = skeletonProbs,
 lambda = lambda) },
 init = function(){ list(theta = 1) }, sample = "theta")
 }


# tox data and model fitting

data <- Data(x = c(1.2,1.2,1.8,2.4,3),
                 y = c(0, 0, 0, 1, 1),
                 cohort = c(1, 1, 2, 3, 4),
                 doseGrid = seq(1.2, 3, 0.6),
                 ID = 1:5,
                 placebo = FALSE)

(skeletonProbs <- round(data@doseGrid / max(data@doseGrid) / 4, 2))

newModel <- OneParExp(skeletonProbs = skeletonProbs,
 doseGrid = data@doseGrid, lambda = 1)

newDLTmodel <- update(object=newModel, data=data)
user1431694
  • 715
  • 1
  • 11
  • 22

1 Answers1

0

You don't use the "update" function here to feed data to the model. ("update" methods are primarily internal methods to update "Data" objects in crmPack.) Instead, you use "mcmc" to estimate parameters given a model and data:

    estimates <- mcmc(model=newModel, data=data, options=McmcOptions())
    plot(estimates, newModel, data)
  • Thanks Daniel. On page 14 of your vignette, you update the DLT model (and the efficacy model) in order to use those in the nextBest function afterwards. Is there a way to use nextBest without updating the DLT and Efficacy models ? I intend to use the power model for the DLTs, and a random walk model for Efficacy (as defined on page 57 of your Examples document) . I've noticed that I couldn't update both with data, and then couldn't use nextBest.. – user1431694 Jun 12 '19 at 16:39