2

I am trying to use a multinomial logistic regression model to determine how different factors influence the liklihood of several behavioral states among two species of shark.

19 individual animals, comprising two distinct species, were each tracked for ~100 days each and a different behavioral state was identified for each day data were collected.

I would like to code individual shark as a categorical random effect variable (with 19 levels) within species, a categorical fixed effect variable (with 2 levels).

With this general idea, the code that I am currently trying to run is:

mclogit::mblogit(cluster ~ species, random = ~1|individual %in% species, data = df, method = "MQL")

The model appears to run normally but produces the error message:

Error in *tmp*[[k]] : subscript out of bounds

Reversing the order of the random effect interaction term produces a different error message. Now the code reads:

mclogit::mblogit(cluster ~ species, random = ~1|species %in% individual, data = df, method = "MQL")

And produces the error:

Error in solve.default(X[[i]], ...) : 'a' (6 x 1) must be square

Here is a sample of the raw data with which I am trying to fit my model:

df <- data.frame(
Date = c("2015-11-25", "2016-01-24", "2016-02-27", "2016-03-27", "2017-12-02", "2017-12-06", "2015-10-30", "2015-10-31"),
cluster = factor(c(3,3,4,6,3,1,3,2)),
species = factor(c("I.oxyrinchus", "I.oxyrinchus", "I.oxyrinchus", "I.oxyrinchus", "P.glauca", "P.glauca", "P.glauca", "P.glauca")),
individual = factor(c("141257", "141257", "141254", "141254", "141256", "141256", "141255", "141255")))

Attempting to run the code with this reduced dataset produces only the second of the two error messages.

My questions are two fold:

  1. What are the meanings of these two error messages, and how might I address one or both of them?

  2. Why might the order of the terms in the random effect portion of the model formula produce two different results?

Thank you.

Aidan Cox
  • 21
  • 1

0 Answers0