Hi folks,
I’m fitting an AR1 model with a single binary condition, and I want to get an individual-level estimate of the effect of condition, shrunk hierarchically as is normal. The model structure is something like:
DV ~ Condition + ar(time = TrialNumber, gr = Subject, p = 1, cov = T) +(1+Condition|Study/Subject))
The model fits great, but then when I feed it a dataframe with one row per subject/study combination with a column for Condition, it complains about not having TrialNumber; when I give each subject a dummy trial number (1 for one level of Condition, 2 for the other) it says trial number must be unique within grouping (which it is, in the new dataframe). When I throw up my hands and just feed it the original dataframe it was trained on to try to get something to work, it gives the error “Error in eval(substitute(expr), data, enclos = parent.frame()) : object ‘begin_tg’ not found” (note that begin_tg isn’t part of my analysis, and I don’t know where it comes from).
Would anyone be willing to give me advice on how to get hierarchically-shrunk estimates of the effect of Condition on each subject out of this model? Currently I’ve resorted to manually grabbing the samples, combining the by-subject-by-study random slope of Condition and the main effect of Condition and re-constructing a linear predictor that way, but that yields very wide estimates which don’t seem terribly helpful (I have reason to suspect the estimates should be at least a little shrunk, since there’s a paper in the literature that uses this technique on the same sort of data to pretty nice effect). Any suggestions would be greatly appreciated! (also I apologize for not uploading my dataset / an anonymized dataset here; it’s not sharable at all).
Best,
Canaan
Edit: tagging @Solomon and @martinmodrak here since it’s basically a new glitch arising from a previous non-AR version of this same model that you guys had very helpful comments about; this one: Errors with BLUPs with complex random effects in brms using posterior_epred)