I have used this small function so far and it seems to work fine. It creates the avgs. for each of the fixed effect variables wrt each of the random effect variables. It should probably better return the formula for the model. I’ll work on that when I have time.
function prepcre!(data, fixedvars, randomvars)
for f in fixedvars
for r in randomvars
transform!(groupby(data, r),
f => mean => "$(f)_$(r)")
end
end
end