Skip to content
Prev 11304 / 20628 Next

Replicating SAS results in R with unstructured covariance matrix

For corSymm, 'form' needs to be:

"a one sided formula of the form ~ t, or ~ t | g, specifying a time covariate t and, optionally, a grouping factor g. A covariate for this correlation structure must be integer valued. When a grouping factor is present in form, the correlation structure is assumed to apply only to observations within the same grouping level; observations with different grouping levels are assumed to be uncorrelated. Defaults to ~ 1, which corresponds to using the order of the observations in the data as a covariate, and no groups."

So, yes, with corSymm(form = ~ 1 | SUBJECT), gls() will assume that the first measurement for a particular subject corresponds to time = 1. If that's not the case (and that can of course happen if rows with missing data have been deleted), then things get misalligned. Then you need the time covariate, so that things can be matched up properly.

Best,
Wolfgang