1

我有一个数据集,其中包含一个分布在 Beta 分布上的相关右删失变量。请不要提供flexsurv软件包。有必要描述我在 AFT 回归生存模型survreg中使用的 Beta 分布的函数。M. Zhu 一书中的一个例子,我替换了我知道的函数,但我无法描述 Beta 分布的密度函数的一阶和二阶导数的比率:

# Beta Distribution - User-defined code for 'survreg'
a = 1.2; b = 0.2

myb <- list (name = "beta",

init = function (x, weights, ...)
{
mean <- sum (x * weights) / sum (weights)
var <- sum (weights * (x - mean) ^ 2) / sum (weights)
c (mean, var)
},

density = function (x, parms)
{
  cbind (
  pb (x, shape1 = a, shape2 = b, ncp = 0), # F - Cumulative Distribution Function
  1 - pb (x, shape1 = a, shape2 = b, ncp = 0), # S = 1 - F - Survival Function
  db (x, shape1 = a, shape2 = b, ncp = 0), # f - Density Function
  ?, # f'/ f - the first derivative of the Density function
  ? # f''/ f - the second derivative of the Density function
)
},

quantile = function (p, parms)
qb(x, shape1 = a, shape2 = b, ncp = 0),

deviance = function (...)
stop("deviance residuals not defined")
)

我相信这是由于基础包rbeta中的函数、gamma函数digamma和函数的导数,但我的数学水平不允许应用它们。trigamma

4

0 回答 0