Survival :: survreg用户定义的Beta分布

时间:2018-07-05 05:51:37

标签: r survival beta-distribution

我有一个数据集,该数据集具有在Beta分布上分布的因果右检变量。请不要提供 flexsurv 软件包。有必要描述我的Beta分布的功能,以用于AFT回归生存模型 survreg 。来自the book 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")
)

我认为这是由于基本包 r <中的beta函数,gamma函数,digammatrigamma函数的派生所致/ strong>,但我的数学级别不允许应用它们。

0 个答案:

没有答案