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

weibull_aft.plot_survival_function: object has no attribute #1562

Open
timscorbett opened this issue Sep 28, 2023 · 15 comments
Open

weibull_aft.plot_survival_function: object has no attribute #1562

timscorbett opened this issue Sep 28, 2023 · 15 comments

Comments

@timscorbett
Copy link

Is this a known issue?
Is there a workaround?

Traceback (most recent call last):
File "lifelines_example.py", line 31, in
weibull_aft.plot_survival_function(ax=axes[0][0])
AttributeError: 'WeibullAFTFitter' object has no attribute 'plot_survival_function'

@CamDavidsonPilon
Copy link
Owner

What is the survival function of an AFT model? The AFT model is conditional (i.e requires covariates). Maybe you want predict_survival_function?

@timscorbett
Copy link
Author

I see an example here on page 11-12
https://buildmedia.readthedocs.org/media/pdf/lifelines/latest/lifelines.pdf

@CamDavidsonPilon
Copy link
Owner

That's the WeibullFitter, not WeibullAFTFitter

@timscorbett
Copy link
Author

timscorbett commented Sep 29, 2023 via email

@CamDavidsonPilon
Copy link
Owner

How can I get the baseline curve alone

There's not really a baseline curve for AFT models (terminology isn't used), but I think you just want to set the covariate to 0 in predict_survival_function.

@timscorbett
Copy link
Author

timscorbett commented Sep 29, 2023

Never mind, I added a relevant constant column T.

  • How do I get the CDF relative to this conditional variable from plot_partial_effects_on_outcome? 1 - weibull_aft.predict_survival_function('T') ?

  • Where can I give the T range as given in plot_partial_effects_on_outcome?

  • As well how do I say, I need these for times t=1..10 ?

  • I see predict_survival_function() gives me as many curves as there are rows in the df. Can there be one prediction per T and one single prediction for the baseline?

@CamDavidsonPilon
Copy link
Owner

@timscorbett
Copy link
Author

That helps. Thanks Cam!

I guess I can get the cumulative distribution function (CDF) as 1-survival from the plot collection of partials.

Is there a confidence interval band fill between for the survival plot? If not, how can I get it?

@CamDavidsonPilon
Copy link
Owner

Is there a confidence interval band fill between for the survival plot? If not, how can I get it?

Unfortunately, not

@timscorbett
Copy link
Author

timscorbett commented Oct 3, 2023 via email

@CamDavidsonPilon
Copy link
Owner

cumulative hazard (t) = int_0^t hazard(s) ds

so it's possible for cumulative_hazard < hazard. Think about how a short spike in a function might affect its integral.

@timscorbett
Copy link
Author

timscorbett commented Oct 5, 2023 via email

@CamDavidsonPilon
Copy link
Owner

Sure, yea, but you should expect very small variation in your log10 variable as a consequence.

@timscorbett
Copy link
Author

timscorbett commented Oct 9, 2023

Is the plot_partial_effects_on_outcome same as a regular weibull(1.75,2.24) plot conditional on T?
Here shape (rho_) = 2.24 and scale (lambda_) = 1.75; based on the results below
My intent is to get upper and lower confidence interval curves for this partial effect based on the interval you provide for rho_.

image

(By the way, there is some literature on confidence intervals for Cox PH survival with covariates. Not sure if those are conditional on a covariate.
https://www.jstor.org/stable/2530904)

@timscorbett
Copy link
Author

timscorbett commented Nov 6, 2023 via email

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

2 participants