Gleb Lerman
Gleb Lerman

Reputation: 1

How to analyze panel data in R using logistic regression (glmmML)?

Currently, I am conducting research on the probability of a CEO leaving the company (binary variable="1" if left). My data is unbalanced panel data for 50 companies with 51 individuals in it for the period 2013-2015.

I was trying to run two regression models (fixed and random effects) using the glmmML package. However, I get the following warning:

pdata <- plm.data(ceodata, index=c("id","year"))
fixed <- glmmboot(left ~ age+tenure+boardappr+ROE, 
   family=binomial(link="logit"), data=pdata, cluster=id)
    Warning messages: 
 1: In model.response(mf, "numeric") : using type = "numeric" with a factor response will be ignored
 2: In glmmbootFit(X, Y, weights, start.coef, cluster, offset, family,  :[glmmboot:] Information non-positive definite. No variance!
 3: In Ops.factor(Y, res$fitted) : ‘/’ not meaningful for factors
 4: In Ops.factor(Y, log(ifelse(Y == 0, 1, Y/res$fitted))) ‘*’ not meaningful for factors
 5: In Ops.factor(1, Y) : ‘-’ not meaningful for factors
 6: In Ops.factor(1, Y) : ‘-’ not meaningful for factors

When I change the set of variables I get the same warning and meaningless regression results. I was wondering if I am doing something wrong or there is an issue with the data I use? Perhaps, someone can share the code to run fixed and random effect models as well as Hausman test for logistic regression?

P.S. The data I use look like this:

Here is the overview of data I use

Upvotes: 0

Views: 2860

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226761

The proximal problem here is that (unlike glm in base R and models copying its pattern) glmmML doesn't allow categorical variables as responses. Presumably

pdata <- transform(pdata,left=as.numeric(left)-1)

(in this particular case, as.numeric(as.character(left)) would give the same results ...) will help with that: it will translate the first factor level to 0 and the second to 1.

I don't know much about glmmML: I gave an answer here showing how to implement a Hausman test for models fitted with stats::glm and lme4::glmer ...

Upvotes: 1

Related Questions