In my experiment, nine toads were housed in one of two enclosure types "Basic" or "Enriched". In either enclosure type they could be in one of four postures "Low", "Medium" "MediumHigh", and "High". I want to know if Enclosure type could predict the posture a toad is in.
The data format has a column for ID, a column for enclosure type (Basic or Enriched) and a column for Posture (Low, Medium, MediumHigh, High).
I started off with some basic code that worked just fine: multinom(Posture ~ EnclosureType, data=ungrouped.drop)
However, I need to account for individual variation among toads (ie a random effect). It doesn't seem that there is any way to add random effects using "multinom". (Please correct me if I'm wrong)
So I turned to the mlogit package and attempted to use the npar aregument to specify the random effect: mlogit(Posture ~ BasicEnriched, rpar=c(ID="n"), data= ungrouped.drop)
I got the following error: Error in dfidx::dfidx(data = data, dfa$idx, drop.index = dfa$drop.index, : The choice variable must have exactly two modalities
Since my choice variable (I believe it's "Posture" but correct me if I'm wrong) has more than two modalities I decided perhaps mlogit wasn't right for my scenario and turned to mclogit instead. (Please correct me if I'm wrong): mclogit(Posture ~ BasicEnriched, random = ~1|ID, data=ungrouped.drop)
And I got this error: Error in mclogit(Posture ~ BasicEnriched, random = ~1 | ID, data = ungrouped.drop) : need response counts and choice set indicators
I think this may be a problem with my data format which would require mlogit.data to reformat. However, the mandatory choice argument converts my non-binary "Posture" variable into a binary "True" or "False" which doesn't seem right. I'm also not sure if my data format is wide, long, vertical, or something else.
Your help is much appreciated!
Aucun commentaire:
Enregistrer un commentaire