Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-added distributions in psm #41

Open
harrelfe opened this issue Apr 12, 2017 · 0 comments
Open

User-added distributions in psm #41

harrelfe opened this issue Apr 12, 2017 · 0 comments

Comments

@harrelfe
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant