How to model effect of continuous predictor on category order data in R?

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.

Questions:

• 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?

migrated from stackoverflow.comJan 4 '17 at 22:20

This question came from our site for professional and enthusiast programmers.

• Not sure why someone was rude and gave you a negative point. But you will get better input on this question from the Overflow's "Cross Validated" stack. That is where 'how-to', 'why-to' and 'my math brain hurts' kind of questions are well received. On this side of the electric fence it is all about code and many are possessive of this space! – bethanyP Jan 4 '17 at 22:01
• Thanks @bethanyP! I think you're right, sorry if I posted in the "wrong" stack. I have flagged the post and asked the moderator to move it. – Nicolas Schuck Jan 4 '17 at 22:17
• I just updated the code example to fix a previous error in how I specified the nested random effects of ID and ROW. I am still not sure about the overall correctness of the code and approach however. – Nicolas Schuck Jan 5 '17 at 23:00