I have a data set with a dependent right-censored variable distributed over the Beta distribution. Please do not offer flexsurv package. It is necessary to describe the function of my Beta distribution for use in the AFT regression survival model survreg. An example from the book M. Zhu, I substituted the functions known to me, but I can not describe the ratio of the first and second derivatives of the density function of the Beta distribution :
# 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")
)
I believe that this is due to the derivatives of the beta
function, the gamma
function, digamma
& trigamma
function in the base package r, but my Math level does not allow them to be applied.