Skip to content

Conditional Logit and PHReg with exact tie handling #2386

Open

Description

@josef-pkt

based on the discussion on the mailing list, the exact tie handling uses the probabilities from a conditional logit (Chamberlain) model.

R survival has clogit implemented as a special case using phcox with small number of discrete time periods and exact tie handling.

This could also be added to our PHReg.

Activity

  1. josef-pkt commented on May 5, 2015

    @josef-pkt
    MemberAuthor

    temporarily parking three functions to be used with ConditionalLogit (Chamberlain) or unbalanced CLogit (McFadden)

    (written based on description in Stata's clogit documentation)

    def prob_total(ni, ki, expxb):
        f2_orig = np.zeros(ni+1)
    
        f1 = np.ones(ni+1)
        for k in range(1, ki+1):
    
            f2 = f2_orig.copy()
            for t in range(k, ni+1):
                f2[t] = f2[t-1] + f1[t-1] * expxb[t-1]
            print(f2)
            f1 = f2
    
        return f2
    
    
    def loglike_one_groups(endog, xb, group_idx):
        """loglike without standard interface
        """
        # use boolean for indexing with mask
        endog = np.asarray(endog, np.bool_)
        expxb_groups = np.add.reduceat(np.exp(xb), group_idx)
        return xb[endog] - np.log(expxb_groups)
    
    def score_one_groups(params, endog, exog, group_idx):
        """loglike without standard interface
        """
        # use boolean for indexing with mask
        endog = np.asarray(endog, np.bool_)
        xb = exog.dot(params)
        expxb_groups = np.add.reduceat(np.exp(xb), group_idx)
        expxb_groups_dp = np.add.reduceat(np.exp(xb)[:,None]*x, group_idx, axis=0)
        return x[endog] - (expxb_groups_dp / expxb_groups[:,None])
    
  2. changed the title [-]Conditional Logit on PHReg with exact tie handling[/-] [+]Conditional Logit and PHReg with exact tie handling[/+] on May 5, 2015
  3. added this to the 0.10 milestone on Apr 21, 2018
  4. josef-pkt commented on Apr 22, 2018

    @josef-pkt
    MemberAuthor

    where is my code for Chamberlain's conditional logit?
    maybe it's called now something else?

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions