drizopoulos / GLMMadaptive

GLMMs with adaptive Gaussian quadrature
https://drizopoulos.github.io/GLMMadaptive/
59 stars 14 forks source link

Issue with data prep for backward formulation #43

Closed mhowland621 closed 2 years ago

mhowland621 commented 2 years ago

Hello,

Thanks for this great package! I am fitting a mixed model for ordinal data (collected from 306 participants at 3 timepoints) and have been able to successfully fit a continuation ratio model under the forward formulation using the example code from: https://drizopoulos.github.io/GLMMadaptive/articles/Ordinal_Mixed_Models.html. However when I try to fit the model under backward formulation (what I would prefer), I run into an issue when using cr_setup() with direction = "backward":

Warning in y == (ncoefs - cuts) : longer object length is not a multiple of shorter object length

The only thing I can think of as to why the vectors may not be matching is that I have missing data for some participants. I'm not sure why this would be an issue with the backward but not forward formulation set-up.

Any thoughts/guidance would be much appreciated!

Thank you,

Mariann

drizopoulos commented 2 years ago

Thanks for reporting this. I would need a reproducible example.

mhowland621 commented 2 years ago

I've attached code and a data file. Please let me know if you need anything else. Thanks so much in advance! df.csv GLMM code.md

mhowland621 commented 2 years ago

Hi,

I just wanted to follow up that I think I did run into this issue because of missing data- I was able to successfully run cr_setup() specifying "backwards" using a dataset with complete cases only (whereas my full dataset had some participants missing the second or third timepoint). I'm trying to look into the process by which cr_setup() generates the extra measurements, cohort variable, etc.- at first thought, I am wondering if it is something like that it starts with the first timepoint for forwards and with the last timepoint for backwards? In which case it would run into an issue with some of my participants missing the last timepoint. I have no idea if this makes any sense, just a thought. I am hoping to fit these models with my full sample including those participants with missing data, so any guidance on if there is a workaround would be much appreciated.

Thank you,

Mariann

drizopoulos commented 2 years ago

Do you have missing data in the response variable? These should be excluded before running the function.