I'm trying to change the format so that all the prices are under one column. End goal is to run a “mixed” multinomial logit model, hence the mlogit.data()
function.
Everything runs fine until you try to open the data frame. that's when I get this error:
r error 4 (Error in [.data.frame
(x, start:min(NROW(x), start + len)) : undefined columns selected ).
What can I do to get this working?
library(mlogit)
choice = read.csv('https://raw.githubusercontent.com/bandcar/Examples/main/choice.csv')
choice <- mlogit.data(choice, shape="wide", varying=5:9, choice="choice")
what the end regression will look like:
mixed <- mlogit(choice ~ 0 | log(income) + female + education + price, data = choice)