# Which mixed model in lme4 best mimics the unstructured covariance in GLS?

I have longitudinal study to analyse. M patients examined at N time points.

I want to run a marginal model via GLS estimation with unstructured residual covariance. But I want also to apply the Kenward-Roger degrees of freedom.

In R, in which I work, this is impossible for the GLS. I have to switch to a mixed model, using the lme4. This one only allows for random effects to be specified.

But I know I can approximate gls by lme4 with some effort. For example, often people simulate the compound symmetry with random intercepts: every patient can have the same correlation over time, but can start from a different value (intercept).

Unstructured covariance means, that every 2 patients at every 2 time points can be different.

Which formula corresponds the best to it?

a) random intercept + slope (for time):

Response ~ Treatment * Time + (1 + Time | PatientID)


b) random slope (for time) only, so all slopes (i.e. different correlations, as I wanted), but the intercepts will be same for all patients:

Response ~ Treatment * Time + (0 + Time | PatientID)


I know, I will need to fix some warnings in the lme4, but that's not a problem. Only the above is my concern.

EDIT: Kindly please, help me in this very problem, don't propose "other solutions" or do not tell me "you do not have to do this", as it does not help me at all.

• There must be a way to use an unstructure covariance matrix with the gls function. If you can't find the trick there there is probably a different implementation of GLS that will do it. Random slopes and intercepts introduce computational problems and complexity. But if you want to mimic an unstructure correlation pattern you may need a random shapes model. Apr 3, 2022 at 18:44
• The GLS naturally supports the "unstructured", it doesn't support the Kenward-Roger. It's a must in my field and I was told no other degrees of freedom will be accepted. Only the lme4 supports this, but it's a different approach. Could you guide me, please, which approach is the closest to the unstructured R in lme4? I'm allowed only to use this very package. So I can choose: either random slopes, or random both. Apr 3, 2022 at 18:50
• @BenBolker maybe you could guide me, please? Apr 4, 2022 at 6:51
• Any method for longitudinal data analysis in frequentist statistics is approximate so I personally wouldn't get so connected to any one method such as Kenward-Rogers. Apr 4, 2022 at 12:59
• Can anyone help me in my problem, rather than telling me it's not my problem? I said that nothing else will be accepted in my work, regardless of whether it's good or not, and I strongly, kindly please guiding me in THIS very problem, rather than giving me twice an advice that doesn't help me. Apr 5, 2022 at 5:40