Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • stcox regression with unobserved heterogeneity: delayed entries or gaps detected

    Hello, I am studying a policy reform by using a duration model (cox proportional hazard).

    When I am running the model without unobserved heterogeneity (stcox [vars]) there are no problems. But when I try to include unobserved heterogeneity (stcox ]vars], shared(id) frailty(gamma)) I get the message: shared(): delayed entries or gaps detected.

    My dataset looks something like this:
    id first year gender reform
    1 0 2005 0 0
    1 0 2006 0 0
    1 1 2007 0 0
    1 0 2008 0 0
    2 0 2002 1 1
    2 0 2003 1 1
    3 0 2007 0 1
    3 0 2008 0 1
    3 1 2009 0 1

    The commands I use are the following:

    stset year, id(id) failure(first)
    stcox reform##age gender if age >=60 & age <=64
    stcox reform##age gender if age >=60 & age <=64, shared(id) frailty(gamma) --> 'delayed entries or gaps detected'.


    I have tried to use:
    * stdes (which indicates no delayed entries or gaps),
    * missable sum [vars] and then deleting the observations with missing values,
    * forceshared which leads to the message: matsize too small set matsize to at least 2103'
    * streg [vars], sist(weibull) shared(id) frailty(gamma)

    Do you have any recommendations or solutions to why I struggle including unobserved heterogeneity in my model?

  • #2
    Welcome to the Stata Forum / Statalist,

    From the Stata Manual, we get:

    shared(varname) specifies that a Cox model with shared frailty be fit. Observations with equal value of varname are assumed to have shared (the same) frailty. Across groups, the frailties are assumed to be gamma-distributed latent random effects that affect the hazard multiplicatively, or, equivalently, the logarithm of the frailty enters the linear predictor as a random offset. Think of a shared-frailty model as a Cox model for panel data. varname is a variable in the data that identifies the groups. shared() is not allowed in the presence of delayed entries or gaps
    Sometimes, delving with origin() when stsetting may be helpful. That said, you may perhaps use zero (instead of year) as a starting point concerning time, next you could count years, then fill the gaps before proceeding.
    Best regards,

    Marcos

    Comment


    • #3
      Hi,

      I am struggling with the same issue. I don't really see why Stata keeps giving false errors.

      I have though found an alternative which is using strmcure command. Here is the journal article: https://ageconsearch.umn.edu/record/...art_st0374.pdf

      Comment

      Working...
      X