Skip to content

Cox PHReg as Poisson model #1764

Open
Open

Description

@josef-pkt

interesting relationship

Stata manual has a description and example how to estimate PHReg with a Poisson model in the ststcox.pdf

This needs stsplit to get repeated observations for each individual. (e.g. split on failure times, an individual gets a record for all intervals prior to failure)

Also, if there is within/across individual heteroscedasticity, then the robust covariance takes repeated observations into account.
I didn't look at the details, the reference for vce(robust) is Lin and Wei JASA 1989 http://www.jstor.org/stable/2290085

One usage illustrated in the Stata example is to estimate piecewise linear hazard rate (with time interval dummies)

(I didn't see what the relationship between Poisson and PHReg is if there are ties, maybe it's Breslow.)

Activity

  1. josef-pkt commented on Jun 17, 2014

    @josef-pkt
    MemberAuthor

    Good, do you know if it's easy to do the stspit with pandas?
    (I just saw this for the first time and haven't thought about any details.

    This looks like a case where we should have a Survival class for data handling/transformation, even if we use plain arrays/data frames in the __init__ of the models.

    My guess is that the Poisson representation will be very useful because it looks like that we can turn Poisson into a generic tool exponential model (with the advantage of reusing lots of generic features)
    (the OLS of exp models)

  2. jseabold commented on Jun 17, 2014

    @jseabold
    Member

    Haven't tried yet. Just getting by with list comprehensions for now. Just need results at this point...

  3. josef-pkt commented on Jun 17, 2014

    @josef-pkt
    MemberAuthor

    (I didn't see that fonnesbeck already has the list comprehension for the data conversion.)

  4. josef-pkt commented on Jun 17, 2014

    @josef-pkt
    MemberAuthor

    Are you using pymc or are you doing this with our Poisson?

  5. jseabold commented on Jun 17, 2014

    @jseabold
    Member

    PyMC. I need to handle spatial correlation, and it's easiest to do in a
    Bayesian setting for the non-linear models.

  6. josef-pkt commented on Jun 17, 2014

    @josef-pkt
    MemberAuthor

    @kshedden This might also be interesting for you.
    I don't know if you get issues and issue comments automatically.

  7. kshedden commented on Jun 17, 2014

    @kshedden
    Contributor

    Yes, I've heard about this but haven't looked into it. If it is useful, we
    could implement it some day as an alternative approach to what we have.

    On Tue, Jun 17, 2014 at 10:06 PM, Josef Perktold [email protected]
    wrote:

    @kshedden https://github.com/kshedden This might also be interesting
    for you.
    I don't know if you get issues and issue comments automatically.

    —
    Reply to this email directly or view it on GitHub
    #1764 (comment)
    .

  8. lminer commented on Oct 24, 2014

    @lminer

    I've been trying to get this to work, but am wondering if it's a dead end because the data size explodes too quickly. Here's a gist of a toy problem: http://nbviewer.ipython.org/gist/lminer/dc06589db2aa558f6858

    Looking at the toy problem it seems like the dataset grows at a factor n^2: each individual gets a new observation for every other person who has died during their lifetime.

  9. kshedden commented on Oct 24, 2014

    @kshedden
    Contributor

    The standard Cox model fit in the usual way also has n^2 complexity, hidden
    in the fact that each person's contribution to the likelihood depends on
    the data of everyone else who is in the risk set at that person's event
    time. This is vectorized away in our code, but it is still there. I've
    never looked carefully at the Poisson approach to doing this to see what
    kind of advantages it may offer.

    On Fri, Oct 24, 2014 at 3:08 PM, Luke Miner [email protected]
    wrote:

    I've been trying to get this to work, but am wondering if it's a dead end
    because the data size explodes too quickly. Here's a gist of a toy problem:
    http://nbviewer.ipython.org/gist/lminer/dc06589db2aa558f6858

    Looking at the toy problem it seems like the dataset grows at a factor
    n^2: each individual gets a new observation for every other person who has
    died during their lifetime.

    —
    Reply to this email directly or view it on GitHub
    #1764 (comment)
    .

  10. josef-pkt commented on Oct 24, 2014

    @josef-pkt
    MemberAuthor

    I saw the cross validated question.

    I looked at it a bit two or three weeks ago, but no working recipes.

    If I understand your factor n^2 correctly: That depends on what you do with the time intervals. If you bin in large samples into discrete time periods with fixed intervals, then a new person doesn't affect other individuals or is affected by other individuals. Each would add the fixed number of binned periods, or the number of periods until death. The sample size would be T * N or less.

    The other possibility is if we can group individuals. Individuals that have the same exog, which works if we have only discrete exog. That approach would end up similar to actuarial life tables, with "cohorts" of identical individuals.
    However, our Poisson and the other models except for GLM binomial do not currently support case weights to do this.

  11. josef-pkt commented on Oct 24, 2014

    @josef-pkt
    MemberAuthor

    @kshedden
    Even with n^2 complexity in the calculations, AFAICS only the full representation as necessary for the Poisson model requires n^2 memory.

    But similar to fft based kernel density estimation, if the sample size becomes really large, then I would expect that there is not much loss if we bin time periods.

  12. josef-pkt commented on Oct 24, 2014

    @josef-pkt
    MemberAuthor

    To add a bit more, because I started to worry about similar things in different context.

    Some estimators or hypothesis test behave pretty badly in small sample, and we could put in quite a bit of (computational) effort to improve the behavior, for example bootstrap with robust standard errors, or jacknife, leave one observation out in other contexts. If we have 10,000 or 100,000 or a Million observations, then the same approach can become very time consuming but in most cases we can expect that the standard asymptotic results that are easy to calculate work well.
    (With finite parameter space or smooth parameter space, I haven't started to worry yet about problems where nobs and k_vars both go off to infinite at the same time.)

    In context: What's the relevance of the tie correction if the sample size becomes very large? (assuming the time points are not completely discrete)

  13. josef-pkt commented on Oct 24, 2014

    @josef-pkt
    MemberAuthor

    (forgot to mention: what's small
    for tests on mean parameters with heteroscedasticity robust covariance, the simulations started at 25 observations, between 100 and 250 the asymptotics starts to kick in and then tests based on asymptotic distributions have the correct size.
    For test on variance parameters in the context of GMM, everything below 1000 observations might be small with large distortions in the size of the hypothesis tests.
    )

  14. lminer commented on Oct 24, 2014

    @lminer

    Your first proposal sounds good. Would it still give similar results to PHReg?

    As I mentioned in the cross validated question, I'm looking into this so I can predict duration using time-varying covariates in python. Another possibility that I'm trying to get my head around is to use a sliding landmark model: http://onlinelibrary.wiley.com/doi/10.1111/j.1467-9469.2006.00529.x/abstract.

    The basic idea seems to be to predict survival of individuals between time t and t + w:

    • take all individuals at risk at time t
    • run a cox treating the time-varying covariates as if they were fixed and ignoring any event after t + w
    • run this over set of time points to build up a complete picture of survival

    The paper proposes a method of aggregating this process into a "landmarking supermodel".

  15. josef-pkt commented on Oct 24, 2014

    @josef-pkt
    MemberAuthor

    I don't know much (anything) about time-varying covariates in the Cox-PHReg. Kerby mentioned it.
    I was reading mainly about Poisson and similar version (another "misuse" of GLM) and at AFT models for cases where we don't have proportional hazard.

    What's your real sample size, and your number of unique event and censoring times?
    Binning time periods will cause a discretization loss compared to continuous time PHReg. How serious it is, will depend on the data. I didn't see any references directly about the effect of binning.
    Articles in actuarial applications most of the time started with the data binned in calender time.

    (Also I haven't looked yet at the details about how to get the integrated hazard or survival function with time-varying covariates. my guess is piecewise linear will be the easiest.)

  16. josef-pkt commented on Oct 27, 2014

    @josef-pkt
    MemberAuthor

    just another reference (partially read after the above)
    http://support.sas.com/resources/papers/proceedings12/168-2012.pdf
    The SAS example assumes there are only 3 opportunities (time points) where covariates can change.
    storage: One record for each changed exog of an individual. Sounds similar to the corresponding version in Stata, IIRC what I read in the Stata documentation.

  17. josef-pkt commented on Oct 31, 2014

    @josef-pkt
    MemberAuthor

    Doesn't sound like lmer. A mixture between PH and MCMC ?
    Skipper mentioned above using pymc.
    Sounds difficult to create anytime soon.

    This reminds me: If individuals show up in several records, then we have repeated measures, panel data, and we can or should use cluster robust standard errors. Stata mentions this.
    We have cluster robust standard errors available for Poisson in discrete, GLM and GEE.

  18. lminer commented on Oct 31, 2014

    @lminer

    The package itself seems to be a mixture between PH and MCMC, but the vignette includes comparisons with glm and lmer fits of poissons.

  19. josef-pkt commented on Oct 31, 2014

    @josef-pkt
    MemberAuthor

    Sorry, I didn't see that.
    The Whitehead reference might be a good starting point. http://www.jstor.org/stable/2346901
    But it looks like there are many recent articles on using GLM for survival/failure/hazard data analysis.

    aside, since I just saw again that there are so many parameters estimated for the baseline hazard:
    I guess that we will/might run into an incidental parameter problem if the number of time points increases with the sample size if there is no smoothness condition imposed on the baseline hazard.
    (The number of parameters increases with the sample size.)
    Although, if Poisson regression produces the same numbers as Cox PHReg, then this wouldn't be the case.

  20. lminer commented on Oct 31, 2014

    @lminer

    Not in academia anymore so I don't have easy access to jstor articles. oh for the day when all journals are open source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions