Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Runze Wang
    @Runze
    @CamDavidsonPilon Thanks for letting me know. Looking forward to the support!
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    Mark Schroering
    @mschroering
    Using the example for the CoxPHFitter here: https://lifelines.readthedocs.io/en/latest/fitters/regression/CoxPHFitter.html#lifelines.fitters.coxph_fitter.CoxPHFitter.fit I am getting the following scipy error: _fblas.error: (offx>=0 && offx<len(x)) failed for 2nd keyword offx: dnrm2:offx=0 This is with v0.24.1
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    Hi @mschroering - what version of scipy do you have installed? You can see with "pip freeze"
    Mark Schroering
    @mschroering
    scipy==1.4.1
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    hrm. And did you install lifelines with pip or anaconda?
    Mark Schroering
    @mschroering

    conda.

    lifelines 0.24.1 pypi_0 pypi

    Cameron Davidson-Pilon
    @CamDavidsonPilon
    it looks like a problem with blas, can you try the advice here? https://github.com/MKLab-ITI/ndvr-dml/issues/17#issuecomment-514904905
    Mark Schroering
    @mschroering

    Hmm.. no luck. I tried it in a python:3.6 docker container and get the same thing.

    root@b09153018446:/# pip freeze
    autograd==1.3
    autograd-gamma==0.4.2
    cycler==0.10.0
    future==0.18.2
    kiwisolver==1.1.0
    lifelines==0.24.1
    matplotlib==3.2.0
    numpy==1.18.1
    pandas==1.0.1
    pyparsing==2.4.6
    python-dateutil==2.8.1
    pytz==2019.3
    scipy==1.4.1
    six==1.14.0

    I did a pip install lifelines to get the above. I don't see scikit-learn or blas.

    Cameron Davidson-Pilon
    @CamDavidsonPilon
    Can you post the stacktrace? And which example is it failing on?
    Mark Schroering
    @mschroering
    >>> from lifelines import CoxPHFitter
    >>>
    >>> df = pd.DataFrame({
    >>>     'T': [5, 3, 9, 8, 7, 4, 4, 3, 2, 5, 6, 7],
    >>>     'E': [1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0],
    >>>     'var': [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2],
    >>>     'age': [4, 3, 9, 8, 7, 4, 4, 3, 2, 5, 6, 7],
    >>> })
    >>>
    >>> cph = CoxPHFitter()
    >>> cph.fit(df, 'T', 'E')
    >>> cph.print_summary()
    >>> cph.predict_median(df)
    This is the example, and I was leaving out the var and age columns as I didn't think they were needed, but apparently they are. It is working now. Sorry for the trouble.
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    ah! Okay! That makes sense - I could reproduce parts of what you saw, and only when I put in a 0d array. This is a bug - thanks for bringing it up!
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    cyonghui81
    @cyonghui81
    Hi Cameron, how do I do a prediction for an individual after I have fit my data using cox regression with time varying covariates ?
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    gnikol85
    @gnikol85
    Hi Cameron, I am using the CoxPHFitter and my data consists of one dummy variable. When I use the function plot_covariate_groups, three survival curves are plotted: a) dummy=1, b)dummy=0 and c)baseline_survival.
    I am struggling to understand why the baseline_survival is different compared to the survival where dummy=0.
    From the theory the baseline_survival is the survival curve where all covariates are 0.
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    @gnikol85 that's a good question. It's depends on how the system defines baseline survival. In lifelines, we define baseline survival not at zero, but at the mean (there are nice reasons to do this). If you want, you can turn off the baseline plot by setting plot_baseline=False in plot_covariate_groups
    gnikol85
    @gnikol85
    Thank you very much Cameron for your response.
    I have another question regarding the "conditional_after" arg in the "predict_survival_function".
    If I want to predict the survival for the censored subjects at time 55 and suppose the last event time is 50.
    Should I use the conditional_after=50 and times=5 or
    conditional_after=None and times=55?
    What is the difference?
    Thank you very much for your time.
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    conditional_after=50 and times=5 is correct. The former is P(T=5 | T > 50), and the latter is P(T=55) and the former represents someone who has lived to atleast 50
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    Oops I am slightly wrong, the first probability above should be: P(T + t =55 | t = 50)
    gnikol85
    @gnikol85
    Thank you very much Cameron.
    So the theory is that we need to adjust the probabilities for the censored group in order to take into consideration that they have survived until T=50. Correct?
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    That's right, but that adjust is done internally in lifelines
    gnikol85
    @gnikol85
    Yes I got it. Thank you for your time. You have been very helpful.
    Alejandro Celemin
    @alejo_celemin_twitter
    Hi Cameron, I used the CoxPHFitter on a dataset with 7 covariates. Two of the covariate coefficients turned out to be negative.
    However, when plotting the baseline_survival curve, it seems these two negative coefficients are neglected. Could you please confirm that is correct?
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    hi @alejo_celemin_twitter - the baseline survival curve is independent of the coefficient values. I'm not sure what you mean by "neglected"?
    Alejandro Celemin
    @alejo_celemin_twitter
    Thanks Cameron, I've read that using the Breslow's estimator it's posible to obtain both H0(t) and S0(t) estimates. Since Breslow's estimator is based upon covariate coefficients, I assume S0(t) estimate depends on coefficients from CoxPHFitter. I would seem like S0(t) from baseline_survival might alternatively be obtained from Breslow's estimator, neglecting the negative coefficients...
    gnikol85
    @gnikol85
    Hi Cameron. I am reading the lifelines docs regarding AFT models and I am struggling to understand what is difference between the ExponentialAFTFitter and an exponential regression.
    Or the WeibullAFTFitter and a weibull regression.
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    @alejo_celemin_twitter it's true that in the calculation of the baseline estimates, we use the coefficient values, but that shouldn't matter to the end user. There's no way to "know" if coefficients have been neglected or not.
    @gnikol85 exponential/weibull AFT is a particular form of exponential/weibull regression, but the two are often talked about interchangeably. Are you looking for a more exact definition?
    gnikol85
    @gnikol85
    Thank you Cameron.
    Actually I am wondering if for example the ExponentialAFTFitter yields the same results with the exponential regression?
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    Yes, up to a change in parameterization. For example, lifelines uses (T/lambda(x)), whereas other exponential regression implementations may use lambda(x) * T
    gnikol85
    @gnikol85
    So, if I understand correctly the AFT is just a different name that justifies the "accelerate or decelerate failure times" property of the regression model??
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    that's right!
    gnikol85
    @gnikol85
    Thank you Cameron. Just wanted to say that you have done a great work with lifelines package. Thank you for distributing..
    Mischa Kotlyar MD
    @DocMischa

    Hey @CamDavidsonPilon ,
    I have a question about the Cox’s proportional hazard model.
    In R I can perform an univariate Cox regression and then a multivariate one. Like in this tutorial: http://www.sthda.com/english/wiki/cox-proportional-hazards-model#compute-the-cox-model

    What is the output of cph.print_summary()? If I fit it to a dataset of let's say expressions of miR21, miR126, miR221 and age in years. Then I assume that the output is based on a multivariable calculation. Am I right?
    So to perform an univariate Cox regression, I would have to test every variable on its own and fit the CoxPHFitter() to every variable on its own (for example using a forloop)?

    I hope you can help.
    Cheers Mischa

    Cameron Davidson-Pilon
    @CamDavidsonPilon

    Hi @DocMischa, i'll answer your questions in sequence:

    What is the output of cph.print_summary()

    It's like the summary() function in R - it displays the coefficients of the variables provided in the call to `fit(), plus information about log-likelihood, etc.

    Am I right?

    Your interpretation is correct, yes.

    So to perform an univariate Cox regression, I would have to test every variable on its own and fit the CoxPHFitter() to every variable on its own (for example using a forloop)?

    that's right!

    Mischa Kotlyar MD
    @DocMischa
    @CamDavidsonPilon Thank you very much for your quick response.
    Cheers Mischa
    gnikol85
    @gnikol85
    Hi Cameron. Sorry to bother you again. I was wondering if lifelines package supports time-varying coefficients in Cox or AFT models?
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    gnikol85
    @gnikol85
    Thank you Cameron. What I wanted to say is that coefficients are time varying/dependent not the covariates.
    But I think I can transform the covatiates as in the link you shared in order to formulate the model for time dependent coefficients
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    whoops! I misread. There's no high-level way to do time-varying coefficients in lifelines, yet, unfortunately
    erin3692
    @erin3692
    Hi, Cameron -- I've been looking at the lifelines documentation on readthedocs for the last couple of days with no problem, but today it seems that many of the links on the left side of the homepage are currently not working (e.g. all of the links under "Univariate Models" such as https://lifelines.readthedocs.io/en/latest/Survival%20analysis%20with%20lifelines.html). I wondered if maybe the pages are being updated, or if some different issue may be causing this?
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    ooh, not sure, I haven't made any changes lately. Let me investigate - thanks for bringing this to my attention @erin3692!
    I think it's a problem on the host (readthedocs) side: https://zepid.readthedocs.io/en/latest/ also has broken links
    hmm, but other RTD sites seem fine...
    Cameron Davidson-Pilon
    @CamDavidsonPilon
    I am currently debugging, but you can use this PDF in the meanwhile: https://lifelines.readthedocs.io/_/downloads/en/latest/pdf/
    erin3692
    @erin3692
    Thanks for checking into this, Cameron! And for the PDF too -- much appreciated!
    steroagna
    @steroagna
    Hi everybody, I read here something about a markov model and I'm trying to develop something similar. I have a dataset of activities, with their duration and other parameters and I want to extract the duration of the current activity and what will be the next one using those data. Is there a way to predict it with lifelines? The best way that I could think of so far was to use lifelines to predict the duration and find the next activity with another function, but maybe I overlooked some magical functions :) Any advice would be appreciated :)