Hello, I am apparently confused about the use of an id parameter for an event history/survival model, and why the EHA documentation for aftreg does not specify one. All assistance and insights are appreciated. Attempting to specifiy an id variable with the documentation example generates an "overlapping intervals" error, so I sorted the original mort dataframe and set subsequent entry times an id to the previous exit time + 0.0001. This allowed me to see the affect of the id parameter on the coefficients and significance tests, and prompted my question. The code I used is shown below, with the results at the bottom. Thanks in advance! Mike head(mort) ## data clearly contains multiple entries for some of the dataframe ids no.id.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort) ## Inital model id.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort, id=id) ## overlapping intervals error mort.sort <- ## ensure records ordered mort[ order(mort$id, mort$enter),] ## remove overlap for (i in 2:nrow(mort.sort)){ if (mort.sort[i,'id'] == mort.sort[i-1,'id']) mort.sort[i,'enter'] <- mort.sort[i-1, 'exit'] + 0.0001 } no.id.aft.sort <- aftreg(Surv(enter, exit, event) ~ ses, data mort.sort) ## initial model on modified df id.aft.sort <- aftreg(Surv(enter, exit, event) ~ ses, id=id, data mort.sort) ## with id parameter #=== output ===========#> no.id.aft.sortCall: aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort.sort) Covariate W.mean Coef Exp(Coef) se(Coef) Wald p ses lower 0.416 0 1 (reference) upper 0.584 -0.347 0.707 0.089 0.000 log(scale) 3.603 36.704 0.065 0.000 log(shape) 0.331 1.393 0.058 0.000 Events 276 Total time at risk 17045 Max. log. likelihood -1391.4 LR test statistic 16.1 Degrees of freedom 1 Overall p-value 6.04394e-05> id.aft.sortCall: aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort.sort, id = id) Covariate W.mean Coef Exp(Coef) se(Coef) Wald p ses lower 0.416 0 1 (reference) upper 0.584 -0.364 0.695 0.090 0.000 log(scale) 3.588 36.171 0.065 0.000 log(shape) 0.338 1.402 0.058 0.000 Events 276 Total time at risk 17045 Max. log. likelihood -1390.8 LR test statistic 17.2 Degrees of freedom 1 Overall p-value 3.3091e-05>
On Mon, May 2, 2011 at 5:38 PM, Mike Harwood <harwood262 at gmail.com> wrote:> Hello, > > I am apparently confused about the use of an id parameter for an event > history/survival model, and why the EHA documentation for aftreg does > not specify one. ?All assistance and insights are appreciated.Which version of eha are you using? The latest version documents the use of 'id'.> Attempting to specifiy an id variable with the documentation example > generates an "overlapping intervals" error,Thanks for pointing this out. It is an error (actually three) in the data frame. The reason is that it is "real" data; and not sufficiently checked by me. I'll fix this in an update soon. Thanks again, G?ran so I sorted the original> mort dataframe and set subsequent entry times an id to the previous > exit time + 0.0001. ?This allowed me to see the affect of the id > parameter on the coefficients and significance tests, and prompted my > question. ?The code I used is shown below, with the results at the > bottom. ?Thanks in advance! > > Mike > > head(mort) ## data clearly contains multiple entries for some of the > dataframe ids > > no.id.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort) ?## > Inital model > id.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort, id=id) > ## overlapping intervals error > > mort.sort <- ## ensure records ordered > ? ?mort[ > ? ? ? ?order(mort$id, mort$enter),] > > ## remove overlap > for (i in 2:nrow(mort.sort)){ > ? ? if (mort.sort[i,'id'] == mort.sort[i-1,'id']) > ? ? ? ? mort.sort[i,'enter'] <- mort.sort[i-1, 'exit'] + 0.0001 > ? ? ? ?} > > no.id.aft.sort <- aftreg(Surv(enter, exit, event) ~ ses, data > mort.sort) ## initial model on modified df > id.aft.sort <- aftreg(Surv(enter, exit, event) ~ ses, id=id, data > mort.sort) ## with id parameter > > > #=== output ===========# >> no.id.aft.sort > Call: > aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort.sort) > > Covariate ? ? ? ? ?W.mean ? ? ?Coef Exp(Coef) ?se(Coef) ? ?Wald p > ses > ? ? ? ? ? lower ? ?0.416 ? ? 0 ? ? ? ? 1 ? ? ? ? ? (reference) > ? ? ? ? ? upper ? ?0.584 ? ?-0.347 ? ? 0.707 ? ? 0.089 ? ? 0.000 > > log(scale) ? ? ? ? ? ? ? ? ? ?3.603 ? ?36.704 ? ? 0.065 ? ? 0.000 > log(shape) ? ? ? ? ? ? ? ? ? ?0.331 ? ? 1.393 ? ? 0.058 ? ? 0.000 > > Events ? ? ? ? ? ? ? ? ? ?276 > Total time at risk ? ? ? ? 17045 > Max. log. likelihood ? ? ?-1391.4 > LR test statistic ? ? ? ? 16.1 > Degrees of freedom ? ? ? ?1 > Overall p-value ? ? ? ? ? 6.04394e-05 >> id.aft.sort > Call: > aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort.sort, > ? ?id = id) > > Covariate ? ? ? ? ?W.mean ? ? ?Coef Exp(Coef) ?se(Coef) ? ?Wald p > ses > ? ? ? ? ? lower ? ?0.416 ? ? 0 ? ? ? ? 1 ? ? ? ? ? (reference) > ? ? ? ? ? upper ? ?0.584 ? ?-0.364 ? ? 0.695 ? ? 0.090 ? ? 0.000 > > log(scale) ? ? ? ? ? ? ? ? ? ?3.588 ? ?36.171 ? ? 0.065 ? ? 0.000 > log(shape) ? ? ? ? ? ? ? ? ? ?0.338 ? ? 1.402 ? ? 0.058 ? ? 0.000 > > Events ? ? ? ? ? ? ? ? ? ?276 > Total time at risk ? ? ? ? 17045 > Max. log. likelihood ? ? ?-1390.8 > LR test statistic ? ? ? ? 17.2 > Degrees of freedom ? ? ? ?1 > Overall p-value ? ? ? ? ? 3.3091e-05 >> > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- G?ran Brostr?m
Thank you, Goran. Please see the package details below:> packageDescription('eha')Encoding: UTF-8 Package: eha Version: 1.3-2 Date: 2011-03-01 Title: Event History Analysis Description: A package for survival and event history analysis License: GPL (>= 3) Author: Göran Broström Depends: R (>= 2.2.0), survival, graphics Maintainer: Göran Broström <gb@stat.umu.se> Packaged: 2011-03-01 14:56:12 UTC; gb Repository: CRAN Date/Publication: 2011-03-01 15:50:52 Built: R 2.13.0; i386-pc-mingw32; 2011-04-15 08:22:36 UTC; windows Mike On Mon, May 2, 2011 at 10:38 AM, Mike Harwood <harwood262@gmail.com> wrote:> Hello, > > I am apparently confused about the use of an id parameter for an event > history/survival model, and why the EHA documentation for aftreg does > not specify one. All assistance and insights are appreciated. > > Attempting to specifiy an id variable with the documentation example > generates an "overlapping intervals" error, so I sorted the original > mort dataframe and set subsequent entry times an id to the previous > exit time + 0.0001. This allowed me to see the affect of the id > parameter on the coefficients and significance tests, and prompted my > question. The code I used is shown below, with the results at the > bottom. Thanks in advance! > > Mike > > head(mort) ## data clearly contains multiple entries for some of the > dataframe ids > > no.id.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort) ## > Inital model > id.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort, id=id) > ## overlapping intervals error > > mort.sort <- ## ensure records ordered > mort[ > order(mort$id, mort$enter),] > > ## remove overlap > for (i in 2:nrow(mort.sort)){ > if (mort.sort[i,'id'] == mort.sort[i-1,'id']) > mort.sort[i,'enter'] <- mort.sort[i-1, 'exit'] + 0.0001 > } > > no.id.aft.sort <- aftreg(Surv(enter, exit, event) ~ ses, data > mort.sort) ## initial model on modified df > id.aft.sort <- aftreg(Surv(enter, exit, event) ~ ses, id=id, data > mort.sort) ## with id parameter > > > #=== output ===========# > > no.id.aft.sort > Call: > aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort.sort) > > Covariate W.mean Coef Exp(Coef) se(Coef) Wald p > ses > lower 0.416 0 1 (reference) > upper 0.584 -0.347 0.707 0.089 0.000 > > log(scale) 3.603 36.704 0.065 0.000 > log(shape) 0.331 1.393 0.058 0.000 > > Events 276 > Total time at risk 17045 > Max. log. likelihood -1391.4 > LR test statistic 16.1 > Degrees of freedom 1 > Overall p-value 6.04394e-05 > > id.aft.sort > Call: > aftreg(formula = Surv(enter, exit, event) ~ ses, data = mort.sort, > id = id) > > Covariate W.mean Coef Exp(Coef) se(Coef) Wald p > ses > lower 0.416 0 1 (reference) > upper 0.584 -0.364 0.695 0.090 0.000 > > log(scale) 3.588 36.171 0.065 0.000 > log(shape) 0.338 1.402 0.058 0.000 > > Events 276 > Total time at risk 17045 > Max. log. likelihood -1390.8 > LR test statistic 17.2 > Degrees of freedom 1 > Overall p-value 3.3091e-05 > > > >[[alternative HTML version deleted]]
On Wed, May 4, 2011 at 2:18 PM, Mike Harwood <maharwood at hotmail.com> wrote:> Thank you, Goran. ?Please see the package details below:Thanks, I have uploaded a corrected version of eha to CRAN. Should be available soon. G?ran [...]