I am estimating a multinomial logit using mlogit
in r.
Is there a way to use a list of variables in the mlogit function, instead of enumerating all the variables in it?
Here is a reproducible example. My question is how can I avoid typing AGE + SEX
in the mlogit
function?
zz <- "Choice AGE SEX
1 42 2
1 8 1
1 37 1
1 8 2
1 7 2
3 50 1
3 69 1
3 63 2
3 37 2
3 37 1
3 9 1
3 6 2
3 32 2
3 42 1
2 62 1
2 60 1
2 68 2
2 69 1
2 60 2
2 45 1"
data <- read.table(text = zz, header = TRUE)
Model <- mlogit(Choice ~ 0 | AGE + SEX | 0 , data, shape ="wide", choice = "Choice")