I am working on building an appropriate model for sequential categorical data in R.
Here is the set up: I have a sequence of categorical predictions whose order I want to analyze. I also have a continuous predictor that is hypothesized to affect transition frequencies between categories. In addition, the data comes from an experiment that was repeated for many subjects.
My approach: I construct a contingency table that contains how often every possible transition was observed. Each row defines the "from" state, and each column the "to" state, so row 5, column 3 contains the frequency with which a transition from category 5 to category 3 was observed. In addition, I build the row-sums of this table to get frequencies of how often a category was predicted overall.
In R: My goal is to model the multilevel dependencies correctly as well as accounting for the fact that it is count data. The dependencies are in my opinion as follows: experimental subject is a random factor, and because all values in one row of the contingency table are not fully independent (they are constrained by how often the "from" category was predicted overall), 'ROW' is a second random factor nested within subject. Also, because the transition probabilities of each row and each subject have a fixed mean (1/number of categories), I assume a fixed intercept. Here is my code:
fit = glmer(formula = cbind(FREQ, ROWSUM-FREQ) ~ PRED + (0 + PRED|ID/ROW), data = my_df, family = binomial)
where FREQ are the above described transition frequencies (vectorized), ROWSUM is the sum of all entries in the table row that a value came from (how often the "from" category was predicted for the from-to transition in question), PRED is the continuous predictor (vectorized, so one value per transition), ID is the factor for subject and ROW is an indicator which row a transition belongs to.
Is my statistical approach/the specification of the random factors correct?
Is is correct to not model a intercept because the proportion data has a fixed mean?
Is my implementation in R correct?