如何计算R中的轮廓似然置信区间?

时间:2016-10-25 03:50:42

标签: r continuous-integration

最近,我应该在使用概率可能性的剂量发现项目中找到CI。 R代码如下:

        # dose      0             5           25            50           100
        ds <- c(rep(0, 152), rep(5, 152), rep(25, 150), rep(50, 153), rep(100, 125)) 

        # result:   3/152        7/152        11/150       45/153       74/125
        y <- c(rep(0, 152-3), rep(1, 3), 
               rep(0, 152 -7), rep(1,7), 
               rep(0, 150 - 11), rep(1,11), 
               rep(0, 153 - 45), rep(1,45), 
               rep(0, 125 - 74), rep(1,74))

        # construct dataframe
        dataframe <- data.frame(dose=ds, y=y)
        result <- nls(y~gamma + delt / (1+exp(-alpha - beta * log(ds))),  dataframe, 
                      start = list(gamma=0.1, delt=.50, alpha = -10, beta = 3) )
        summary(result)

结果是:

            Formula: y ~ gamma + delt/(1 + exp(-alpha - beta * log(ds)))

            Parameters:
                   Estimate Std. Error t value Pr(>|t|)    
            gamma   0.03269    0.01938   1.686   0.0921 .  
            delt    0.63921    0.11862   5.389 9.58e-08 ***
            alpha -13.43164    5.03413  -2.668   0.0078 ** 
            beta    3.33924    1.35348   2.467   0.0138 *  

估计是好的,然后,我计算个人资料CI使用Bhat包:

nlogf <- function (x) {
    gamma <- x[1]  # E0
    delta <- x[2]  # Emax
    alpha <- x[3]  #
    beta <- x[4]   # 
    # calculate the probability
    p <- gamma + delta / (1 + exp(-alpha - beta * log(ds)))

    # calculate log likehood (binominal distribution)
    return(-sum(y * log(p) + (1-y) * log(1 - p)))
}
parnames <- c("gamma", "delta", "alpha", "beta")
initV <- c(0.03269,0.63921, -13.43164, 3.33924)
x <- list( label = parnames,
           est = initV,
           low = c(0.02, 0.6,  -14,  3.1),
           upp = c(0.04, 0.7,   -13, 3.5)
)
plkhci(x, nlogf, "alpha")

但结果是:

neg. log. likelihood:  260.4944 

 will attempt to compute both bounds (+/- direction) 

trying lower bound ------------------------ 
starting at:    3.743719 
initial guess:  0.03027769 0.683508 -13.00019 3.102256 

begin Newton-Raphson search for profile lkh conf. bounds: 
eps value for stop criterium: 0.001 
nmax                        : 10 
Error in ftrf(x$est, x$low, x$upp) : ftrf requires x > xl
In addition: Warning message:
In logit.hessian(x0, nlogf, del, dapprox = FALSE, nfcn) :
  hessian not pos. definite

似乎plkhci无法融合。 我能做什么?

0 个答案:

没有答案