harrelfe / rms

Regression Modeling Strategies

Home Page:https://hbiostat.org/R/rms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User-added distributions in psm

harrelfe opened this issue · comments

I am writing you regarding the rms package of which you are the author. I have a rather specific question, which has been posed before on stack-exchanged but without an answer, so I hope you can find the time to look into it.
For my PhD in modelling of drug exposure prior to hematopoietic cell transplantation I am trying to generate a plot using your “rms-package’.
More specifically, I want to use the predict function on a survival model and have done so successfully using the following code:

#——start Code——#

dd <- datadist(Biomarker)
options(datadist='dd’)
S<-Surv(Time,Event)
Weibull: f <- psm(S ~ rcs(Biomarker,4)+gr2, dist="weibull”) #parametric option
Cox: f <- cph(S ~ rcs(Biomarker,4)+gr2, x=TRUE, y=TRUE) #semi parametric option
plot(dm=Predict(f, Biomarker))

#——End Code——#

The problem I encounter is that the survival of our cohort typically follows a Gompertz distribution, not a Weibull.
This distribution is not taken up into “survreg.distributions” and therefore no default option. As I scroll to the code via ''getAnywere(psm)”, I notice an option where a list could be imputed instead of a character.
However, when I try this with the example given in the “survreg” helpfile (MyCauchy), it gives the following warnings/error:

#——start Code——#

mycauchy <- list(name='Cauchy',
init= function(x, weights, ...)
c(median(x), mad(x)),
density= function(x, parms) {
temp <- 1/(1 + x^2)
cbind(.5 + atan(x)/pi, .5+ atan(-x)/pi,
temp/pi, -2 xtemp, 2temp(4x^2temp -1))
},
quantile= function(p, parms) tan((p-.5)*pi),
deviance= function(...) stop('deviance residuals not defined')
)

f <- survreg(S ~ rcs(Flu,4)+gr2, dist=mycauchy)
#no error follows the above with survreg
f <- psm(S ~ rcs(Flu,4)+gr2, dist=mycauchy)
Warning messages:
1: In if (dist == "extreme") warning("Unlike earlier versions of survreg, dist="extreme" does not fit\na Weibull distribution as it uses an identity link. To fit the Weibull\ndistribution use the default for dist or specify dist="weibull".") :
the condition has length > 1 and only the first element will be used
2: In if (dist %in% c("weibull", "exponential", "lognormal", "loglogistic")) c("log(T)", :
the condition has length > 1 and only the first element will be used

f
Error in survreg.distributions[[dist]] : invalid subscript type 'list'

Jurgen Langenhorst
PhD Candidate / Pharmacist
UMC Utrecht
The Netherlands
J.B.Langenhorst-2@umcutrecht.nl