Skip to content

Commit

Permalink
fixinfg AJ plotting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Sep 11, 2019
1 parent 8843bc7 commit c2c0624
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
48 changes: 27 additions & 21 deletions CHANGELOG.md
@@ -1,4 +1,10 @@
### Changelog
## Changelog

#### 0.22.5 - unreleased

##### Bug fixes
- Fixed issue where `fit_interval_censoring` wouldn't accept lists.
- Fixed an issue with `AalenJohansenFitter` failing to plot confidence intervals.


#### 0.22.4 - 2019-09-04
Expand Down Expand Up @@ -68,7 +74,7 @@
- improvements in data validation for `CoxTimeVaryingFitter`


#### 0.22.0 - 2019-07-03
### 0.22.0 - 2019-07-03

##### New features
- Ability to create custom parametric regression models by specifying the cumulative hazard. This enables new and extensions of AFT models.
Expand Down Expand Up @@ -136,7 +142,7 @@ I'm skipping 0.21.4 version because of deployment issues.
##### Bug fixes
- fixed bug in CoxTimeVaryingFitter when ax is provided, thanks @j-i-l!

#### 0.21.0 - 2019-04-12
### 0.21.0 - 2019-04-12

##### New features
- `weights` is now a optional kwarg for parametric univariate models.
Expand Down Expand Up @@ -217,7 +223,7 @@ I'm skipping 0.21.4 version because of deployment issues.
- Previously, lifelines _always_ added a 0 row to `cph.baseline_hazard_`, even if there were no event at this time. This is no longer the case. A 0 will still be added if there is a duration (observed or not) at 0 occurs however.


#### 0.20.0 - 2019-03-05
### 0.20.0 - 2019-03-05

- Starting with 0.20.0, only Python3 will be supported. Over 75% of recent installs where Py3.
- Updated minimum dependencies, specifically Matplotlib and Pandas.
Expand Down Expand Up @@ -273,7 +279,7 @@ I'm skipping 0.21.4 version because of deployment issues.
- **Important**: we changed the parameterization of the `PiecewiseExponential` to the same as `ExponentialFitter` (from `\lambda * t` to `t / \lambda`).


#### 0.19.0 - 2019-02-20
### 0.19.0 - 2019-02-20

##### New features
- New regression model `WeibullAFTFitter` for fitting accelerated failure time models. Docs have been added to our [documentation](https://lifelines.readthedocs.io/) about how to use `WeibullAFTFitter` (spoiler: it's API is similar to the other regression models) and how to interpret the output.
Expand Down Expand Up @@ -329,13 +335,13 @@ I'm skipping 0.21.4 version because of deployment issues.
- `LogNormalFitter` no longer models `log_sigma`.


#### 0.18.1 2019-02-02
#### 0.18.1 - 2019-02-02
- bug fixes in `LogNormalFitter` variance estimates
- improve convergence of `LogNormalFitter`. We now model the log of sigma internally, but still expose sigma externally.
- use the `autograd` lib to help with gradients.
- New `LogLogisticFitter` univariate fitter available.

#### 0.18.0 - 2019-01-31
### 0.18.0 - 2019-01-31

- `LogNormalFitter` is a new univariate fitter you can use.
- `WeibullFitter` now correctly returns the confidence intervals (previously returned only NaNs)
Expand Down Expand Up @@ -374,7 +380,7 @@ I'm skipping 0.21.4 version because of deployment issues.
- Fixes a Pandas performance warning in `CoxTimeVaryingFitter`.
- Performances improvements to `CoxTimeVaryingFitter`.

#### 0.17.0 - 2019-01-11
### 0.17.0 - 2019-01-11

- corrected behaviour in `CoxPHFitter` where `score_` was not being refreshed on every new `fit`.
- Reimplentation of `AalenAdditiveFitter`. There were significant changes to it:
Expand All @@ -399,7 +405,7 @@ I'm skipping 0.21.4 version because of deployment issues.
#### 0.16.1 - 2019-01-01
- Fixed py2 division error in `concordance` method.

#### 0.16.0 - 2019-01-01
### 0.16.0 - 2019-01-01

- Drop Python 3.4 support.
- introduction of residual calculations in `CoxPHFitter.compute_residuals`. Residuals include "schoenfeld", "score", "delta_beta", "deviance", "martingale", and "scaled_schoenfeld".
Expand Down Expand Up @@ -432,7 +438,7 @@ I'm skipping 0.21.4 version because of deployment issues.
- Bug fixes for v0.15.0
- Raise NotImplementedError if the `robust` flag is used in `CoxTimeVaryingFitter` - that's not ready yet.

#### 0.15.0 - 2018-11-22
### 0.15.0 - 2018-11-22
- adding `robust` params to `CoxPHFitter`'s `fit`. This enables atleast i) using non-integer weights in the model (these could be sampling weights like IPTW), and ii) mis-specified models (ex: non-proportional hazards). Under the hood it's a sandwich estimator. This does not handle ties, so if there are high number of ties, results may significantly differ from other software.
- `standard_errors_` is now a property on fitted `CoxPHFitter` which describes the standard errors of the coefficients.
- `variance_matrix_` is now a property on fitted `CoxPHFitter` which describes the variance matrix of the coefficients.
Expand Down Expand Up @@ -489,14 +495,14 @@ I'm skipping 0.21.4 version because of deployment issues.
- Performance optimizations in `AalenAdditiveFitter` for up to 50% faster completion of `fit` for large dataframes, and up to 10% faster for small dataframes.


#### 0.14.0 - 2018-03-03
### 0.14.0 - 2018-03-03
- adding `plot_covariate_groups` to `CoxPHFitter` to visualize what happens to survival as we vary a covariate, all else being equal.
- `utils` functions like `qth_survival_times` and `median_survival_times` now return the transpose of the DataFrame compared to previous version of lifelines. The reason for this is that we often treat survival curves as columns in DataFrames, and functions of the survival curve as index (ex: KaplanMeierFitter.survival_function_ returns a survival curve _at_ time _t_).
- `KaplanMeierFitter.fit` and `NelsonAalenFitter.fit` accept a `weights` vector that can be used for pre-aggregated datasets. See this [issue](https://github.com/CamDavidsonPilon/lifelines/issues/396).
- Convergence errors now return a custom `ConvergenceWarning` instead of a `RuntimeWarning`
- New checks for complete separation in the dataset for regressions.

#### 0.13.0 - 2017-12-22
### 0.13.0 - 2017-12-22
- removes `is_significant` and `test_result` from `StatisticalResult`. Users can instead choose their significance level by comparing to `p_value`. The string representation of this class has changed aswell.
- `CoxPHFitter` and `AalenAdditiveFitter` now have a `score_` property that is the concordance-index of the dataset to the fitted model.
- `CoxPHFitter` and `AalenAdditiveFitter` no longer have the `data` property. It was an _almost_ duplicate of the training data, but was causing the model to be very large when serialized.
Expand All @@ -507,7 +513,7 @@ I'm skipping 0.21.4 version because of deployment issues.
- `CoxPHFitter` has a slightly more intelligent (barely...) way to pick a step size, so convergence should generally be faster.
- `CoxPHFitter.fit` now has accepts a `weight_col` kwarg so one can pass in weights per observation. This is very useful if you have many subjects, and the space of covariates is not large. Thus you can group the same subjects together and give that observation a weight equal to the count. Altogether, this means a much faster regression.

#### 0.12.0
### 0.12.0
- removes `include_likelihood` from `CoxPHFitter.fit` - it was not slowing things down much (empirically), and often I wanted it for debugging (I suppose others do too). It's also another exit condition, so we many exit from the NR iterations faster.
- added `step_size` param to `CoxPHFitter.fit` - the default is good, but for extremely large or small datasets this may want to be set manually.
- added a warning to `CoxPHFitter` to check for complete seperation: https://stats.idre.ucla.edu/other/mult-pkg/faq/general/faqwhat-is-complete-or-quasi-complete-separation-in-logisticprobit-regression-and-how-do-we-deal-with-them/
Expand All @@ -525,15 +531,15 @@ I'm skipping 0.21.4 version because of deployment issues.
#### 0.11.1 - 2017-06-22
- Python3 fix for `CoxPHFitter.plot`.

#### 0.11.0 - 2017-06-21
### 0.11.0 - 2017-06-21
- fixes regression in `KaplanMeierFitter.plot` when using Seaborn and lifelines.
- introduce a new `.plot` function to a fitted `CoxPHFitter` instance. This plots the hazard coefficients and their confidence intervals.
- in all plot methods, the `ix` kwarg has been deprecated in favour of a new `loc` kwarg. This is to align with Pandas deprecating `ix`

#### 0.10.1 - 2017-06-05
- fix in internal normalization for `CoxPHFitter` predict methods.

#### 0.10.0
### 0.10.0
- corrected bug that was returning the wrong baseline survival and hazard values in `CoxPHFitter` when `normalize=True`.
- removed `normalize` kwarg in `CoxPHFitter`. This was causing lots of confusion for users, and added code complexity. It's really nice to be able to remove it.
- correcting column name in `CoxPHFitter.baseline_survival_`
Expand All @@ -555,7 +561,7 @@ I'm skipping 0.21.4 version because of deployment issues.
#### 0.9.1
- add two summary functions to Weibull and Exponential fitter, solves #224

#### 0.9.0
### 0.9.0
- new prediction function in `CoxPHFitter`, `predict_log_hazard_relative_to_mean`, that mimics what R's `predict.coxph` does.
- removing the `predict` method in CoxPHFitter and AalenAdditiveFitter. This is because the choice of `predict_median` as a default was causing too much confusion, and no other natual choice as a default was available. All other `predict_` methods remain.
- Default predict method in `k_fold_cross_validation` is now `predict_expectation`
Expand All @@ -568,7 +574,7 @@ I'm skipping 0.21.4 version because of deployment issues.
- scaling of smooth hazards in NelsonAalenFitter was off by a factor of 0.5.


#### 0.8.0
### 0.8.0
- reorganized lifelines directories:
- moved test files out of main directory.
- moved `utils.py` into it's own directory.
Expand All @@ -589,7 +595,7 @@ categorical variables in your dataset.
- refactor each fitter into it's own submodule. For now, the tests are still in the same file. This will also *not* break the API.


#### 0.7.0 - 2015-03-01
### 0.7.0 - 2015-03-01
- allow for multiple fitters to be passed into `k_fold_cross_validation`.
- statistical tests in `lifelines.statistics`. now return a `StatisticalResult` object with properties like `p_value`, `test_results`, and `summary`.
- fixed a bug in how log-rank statistical tests are performed. The covariance matrix was not being correctly calculated. This resulted in slightly different p-values.
Expand All @@ -602,7 +608,7 @@ categorical variables in your dataset.
so if your work is to sum up the survival function (for expected values or something similar), it's more difficult to
make a mistake.

#### 0.6.0 - 2015-02-04
### 0.6.0 - 2015-02-04

- Inclusion of the univariate fitters `WeibullFitter` and `ExponentialFitter`.
- Removing `BayesianFitter` from lifelines.
Expand All @@ -626,7 +632,7 @@ is `smoothing_penalizer`.
- Adding "At Risk" counts option to univariate fitter `plot` methods, `.plot(at_risk_counts=True)`, and the function `lifelines.plotting.add_at_risk_counts`.
- Fix bug Epanechnikov kernel.

#### 0.5.0 - 2014-12-07
### 0.5.0 - 2014-12-07

- move testing to py.test
- refactor tests into smaller files
Expand Down Expand Up @@ -683,7 +689,7 @@ is `smoothing_penalizer`.
- Adding a Changelog.
- more sanitizing for the statistical tests =)

#### 0.4.0 - 2014-06-08
### 0.4.0 - 2014-06-08

- `CoxFitter` implements Cox Proportional Hazards model in lifelines.
- lifelines moves the wheels distributions.
Expand Down
6 changes: 4 additions & 2 deletions lifelines/fitters/aalen_johansen_fitter.py
Expand Up @@ -39,10 +39,12 @@ class AalenJohansenFitter(UnivariateFitter):
Example
-------
>>> from lifelines import AalenJohansenFitter
>>> from lifelines.datasets import load_waltons
>>> T, E = load_waltons()['T'], load_waltons()['E']
>>> ajf = AalenJohansenFitter(calculate_variance=True)
>>> ajf.fit(T, E)
>>> ajf.fit(T, E, event_of_interest=1)
>>> ajf.cumulative_density_
>>> ajf.plot()
Expand Down Expand Up @@ -155,7 +157,6 @@ def fit(

self._label = label
self.cumulative_density_ = pd.DataFrame(aj[cmprisk_label])
self.confidence_interval_cumulative_density_ = self.cumulative_density_

# Technically, cumulative incidence, but consistent with KaplanMeierFitter
self.event_table = aj[
Expand All @@ -169,6 +170,7 @@ def fit(
else:
self.variance_, self.confidence_interval_ = None, None

self.confidence_interval_cumulative_density_ = self.confidence_interval_
return self

def _jitter(self, durations, event, jitter_level, seed=None):
Expand Down

0 comments on commit c2c0624

Please sign in to comment.