Multinomial Logit Model for Panel Data including a Random Term

873 views Asked by At

I do have a panel-data set which can be mimicked by:

set.seed(123)
N = 1000
X2 = runif(N, 0, 1)
X1 = sample(0:6, N, replace=TRUE)
eps = rnorm(N, 0, 6)
length = sample(1:4,N,replace=TRUE)
Ycont = 0.5*X2 - 0.3*X1 +0.2*length + 10 + eps
Y = ntile(Ycont, 3)
Y =Y - 1
df_org  = data.frame(id=as.character(1:N), length, Y, X1, X2)
df_org[df_org$length==2 & df_org$Y==1,]$Y=0 # keine Ausfälle in t2
df = df_org
# Data-Manipulation
df_long = setDT(df_org)[,.SD[rep(1L,(length))], by = id]
# add length-variable:
df_long = df_long[ , time := 1:.N, by=id]
# correct dependent variable
df_long$Y_new = df_long$Y
df_long[df_long$time < df_long$length,]$Y_new = 0
df_long$int_time = as.factor(df_long$time)

I now want to fit a multinomial logit model with a random term for each individual - identified by it's ID.

Without the random term, my model is calculated as:

reg_surv=multinom(Y_new~-1+int_time+X1+X2,data=df_long,maxit=500,MaxNWts =2000)

I read that I need to estimate a mass point mixed multinomial logit model. But how to accomplish this in R?

1

There are 1 answers

0
Joaquin On

I am not very sure about the mass point part, but you can add random effects in R by including the individual ID as factor in your model. This effectively adds individual level dummies to your model (this is a dummy variable for each individual) and "allows" your intercept to vary at the individual level, measuring the difference between a given individual and the average "score."

Further reading: https://en.wikipedia.org/wiki/Random_effects_model