Skip to content

Commit

Permalink
Merge pull request statsmodels#1825 from josef-pkt/phreg_1312_rebased
Browse files Browse the repository at this point in the history
ENH: Cox Proportional Hazard Model, Phreg rebased closes statsmodels#1312
  • Loading branch information
josef-pkt committed Jul 11, 2014
2 parents 0f93544 + 3e26235 commit 9aea814
Show file tree
Hide file tree
Showing 21 changed files with 3,886 additions and 5 deletions.
81 changes: 81 additions & 0 deletions docs/source/duration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
.. currentmodule:: statsmodels.duration.hazard_regression


.. _duration:

Models for Survival and Duration Analysis
=========================================

currently contains Cox's Proportional Hazard Model.


Examples
--------

::

url = "http://vincentarelbundock.github.io/Rdatasets/csv/survival/flchain.csv"
data = pd.read_csv(url)
del data["chapter"]
data = data.dropna()
data["lam"] = data["lambda"]
data["female"] = 1*(data["sex"] == "F")
data["year"] = data["sample.yr"] - min(data["sample.yr"])

status = np.asarray(data["death"])
mod = PHreg.from_formula("futime ~ 0 + age + female + creatinine + " +
"np.sqrt(kappa) + np.sqrt(lam) + year + mgus",
data, status=status, ties="efron")
rslt = mod.fit()
print(rslt.summary())

Detailed examples can be found here:

.. toctree::
:maxdepth: 2

examples/notebooks/generated/ not yet

There some notebook examples on the Wiki:
`Wiki notebooks for PHReg and Survival Analysis <https://github.com/statsmodels/statsmodels/wiki/Examples#survival-analysis>`_



Technical Documentation
-----------------------

TODO


References
^^^^^^^^^^

References for Cox proportional hazards regression model::

T Therneau (1996). Extending the Cox model. Technical report.
http://www.mayo.edu/research/documents/biostat-58pdf/DOC-10027288

G Rodriguez (2005). Non-parametric estimation in survival models.
http://data.princeton.edu/pop509/NonParametricSurvival.pdf

B Gillespie (2006). Checking the assumptions in the Cox proportional
hazards model.
http://www.mwsug.org/proceedings/2006/stats/MWSUG-2006-SD08.pdf


Module Reference
----------------

The model class is:

.. autosummary::
:toctree: generated/

PHReg

The result classe is:

.. autosummary::
:toctree: generated/

PHRegResults
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Table of Contents
discretemod
anova
tsa
duration
stats
nonparametric
gmm
Expand Down
7 changes: 3 additions & 4 deletions docs/source/release/version0.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Major changes:
Addition of Generalized Estimating Equations GEE

Generalized Estimating Equations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------------

Generalized Estimating Equations (GEE) provide an approach to handling
dependent data in a regression analysis. Dependent data arise
Expand Down Expand Up @@ -63,9 +63,8 @@ errors that are approximately correct even if the working dependence
structure is misspecified.



Seasonality Plots
~~~~~~~~~~~~~~~~~
-----------------

Adding functionality to look at seasonality in plots. Two new functions are :func:`sm.graphics.tsa.month_plot` and :func:`sm.graphics.tsa.quarter_plot`. Another function :func:`sm.graphics.tsa.seasonal_plot` is available for power users.

Expand Down Expand Up @@ -106,7 +105,7 @@ We added a naive seasonal decomposition tool in the same vein as R's ``decompose
Addition of Linear Mixed Effects Models (MixedLM)

Linear Mixed Effects Models
~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------

Linear Mixed Effects models are used for regression analyses involving
dependent data. Such data arise when working with longitudinal and
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def get_data_files():
# add all the tests and results files
for r, ds, fs in os.walk(pjoin(curdir, "statsmodels")):
r_ = relpath(r, start=curdir)
if r_.endswith('results') and 'sandbox' not in r_:
if r_.endswith('results'):
data_files.update({r_.replace(sep, ".") : ["*.csv",
"*.txt"]})

Expand Down
1 change: 1 addition & 0 deletions statsmodels/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .discrete.discrete_model import (Poisson, Logit, Probit,
MNLogit, NegativeBinomial)
from .tsa import api as tsa
from .duration.hazard_regression import PHReg
from .nonparametric import api as nonparametric
from . import distributions
from .__init__ import test
Expand Down
Empty file.
Loading

0 comments on commit 9aea814

Please sign in to comment.