You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
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)
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.
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:
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)
.
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.
@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.
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)
(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.
)
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.)
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.
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.
Activity
jseabold commentedon Jun 17, 2014
I'm working on something similar at the moment
http://nbviewer.ipython.org/gist/fonnesbeck/5214637
josef-pkt commentedon Jun 17, 2014
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
Survivalclass 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
expmodels)jseabold commentedon Jun 17, 2014
Haven't tried yet. Just getting by with list comprehensions for now. Just need results at this point...
josef-pkt commentedon Jun 17, 2014
(I didn't see that fonnesbeck already has the list comprehension for the data conversion.)
josef-pkt commentedon Jun 17, 2014
Are you using pymc or are you doing this with our Poisson?
jseabold commentedon Jun 17, 2014
PyMC. I need to handle spatial correlation, and it's easiest to do in a
Bayesian setting for the non-linear models.
josef-pkt commentedon Jun 17, 2014
@kshedden This might also be interesting for you.
I don't know if you get issues and issue comments automatically.
kshedden commentedon Jun 17, 2014
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:
lminer commentedon Oct 24, 2014
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.
kshedden commentedon Oct 24, 2014
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:
josef-pkt commentedon Oct 24, 2014
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.
josef-pkt commentedon Oct 24, 2014
@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.
josef-pkt commentedon Oct 24, 2014
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)
josef-pkt commentedon Oct 24, 2014
(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.
)
lminer commentedon Oct 24, 2014
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:
The paper proposes a method of aggregating this process into a "landmarking supermodel".
josef-pkt commentedon Oct 24, 2014
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.)
josef-pkt commentedon Oct 27, 2014
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.
lminer commentedon Oct 31, 2014
Found another reference that shows how to fit a cox with frailty terms as a poisson in r using lmer: http://cran.r-project.org/web/packages/phmm/vignettes/phmm_poisson_df.pdf
josef-pkt commentedon Oct 31, 2014
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.
lminer commentedon Oct 31, 2014
The package itself seems to be a mixture between PH and MCMC, but the vignette includes comparisons with glm and lmer fits of poissons.
josef-pkt commentedon Oct 31, 2014
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.
lminer commentedon Oct 31, 2014
Not in academia anymore so I don't have easy access to jstor articles. oh for the day when all journals are open source.
kshedden commentedon Apr 8, 2015
Now available in Stata 14:
http://www.stata.com/stata-news/news30-1/multilevel-survival-models/?utm_source=MailingList&utm_medium=email&utm_content=20150407+Stata+14+ENEWS