我已经按照crmPack插图(第16-17页)中提供的代码来定义单参数功率模型。我将需要使用更新功能为其提供一些毒性数据,但是我得到的错误是“没有名称为“ call”的插槽”。这是下面的代码。对于“解决”这个问题,我将不胜感激。非常感谢。
# 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)
答案 0 :(得分:0)
您无需在此处使用“更新”功能来将数据输入模型。 (“更新”方法主要是用于更新crmPack中“数据”对象的内部方法。)相反,您可以使用“ mcmc”来估计给定模型和数据的参数:
estimates <- mcmc(model=newModel, data=data, options=McmcOptions())
plot(estimates, newModel, data)