I have a set of results from a choice experiment that I am trying to analyse using the mlogit function in R. My data set is shown below, where each STR value represents the three choices in a single choice experiment, 'CHOICE' is a binary variable indicating which the participant selected, and columns C-G detail the attributes of each choice (D-G being binary variables - 1=yes, 0=no).
I am trying to run the model as:
m <- mlogit(CHOICE ~ PRICE + GreenStatement + Certification + MediumBrand + HighBrand, SP1, choice = "CHOICE", shape = "long", alt.levels = "STR")
but get the error "contrasts can be applied only to factors with 2 or more levels". I have tried running 'as.factor' on all the variables, so they are different factors, and asking R to display a data summary tells me that they all have 2 or more levels. But I still get this error. Would anyone please be able to help me identify (and fix!) the source of this error?