5
$\begingroup$

I am bewildered by multilevel mixed-models that have pseudo-repeats. I have difficulty understanding which variables should be considered REPEATED within a mixed-model context, and WHY. In a classical sense, where repeated measurements are literally repeated over time, it is straightforward. But in the case of pseudo-repeated variables, it is really difficult and vague. I can't decide clearly if I should designate those pseudo-repeated variables as REPEATED.

This REPEATED feature of SPSS is truly confusing. Anyone can understand it completely? By completely, I need to know exactly which variables should be put as REPEATED and why; and if those REPEATED ones should be necessarily nested or not; and whether or not those REPEATED ones should be necessarily modeled as random effects or not.

eg, SPSS allows a variable be designated as REPEATED but not as RANDOM. And in that case, SPSS treats the REPEATED variable as a form of RANDOM effect (or Does it? I am not sure but I hope so, only implied from all the vague and incomplete SPSS tutorials I have seen).

Still, one can designate a variable as REPEATED, and also as set it as RANDOM at the same time! Quite counterintuitive and strange. Or one can designate a variable as REPEATED and RANDOM, and then nest it within SUBJECT or within another RANDOM effect! Very confusing. Worst part is that there is no explicit tutorial on it.


By "pseudo-repeated" variables, I mean this:

Imagine I want to see which variables influence the 'limb length', as the dependent variable. The independent variables are sex, age, height, ethnic background, as well as Side (2 levels: left or right) and Limb (4 levels: hand, arm, leg, foot).

Question: In SPSS or in any other software, should I designate the 2 variables Side (left/right) and Limb (hand/arm/leg/foot) as REPEATED (and nest them within the SUBJECT variable) or not? WHY?

(Question 2 about R vs SPSS at the end.)


Note 1: There is no 'time' variable; each limb has been measured only once. So there is No repeated measurement in its classical sense of "time". Yet there is almost perfect correlation between the right and left limbs; and also between different limbs of one person. So it makes sense if we consider Side and Limb as repeated.

Note 2:SUBJECT has been designated. It already does tell the model that within each subject, there is a strong correlation (dependence) between left and right sides, or between different types of limbs, or between all the 8 items (2 sides * 4 limbs). All of this info is already given to the model by the SUBJECT ID. So Why bother adding more emphasis on potential correlations between them by designating additional REPEATED variables?

IMPORTANT Note 3: I remember about 10 years ago, some really experienced expert on CV (was it Peter Flom?) said that in such cases, we should only define SUBJECT and disregard any REPEATED because SUBJECT alone suffices for accounting for the randomness. But I can't find that good answer.

Note 4: In SPSS, when the user designates a variable as REPEATED, this variable can be later NESTED; but it can also be left Not NESTED, and just REPEATED. Each of these have its own different meaning and output. So I am not necessarily talking about nesting.


The above example is just made up to ask which items should be treated as REPEATED, and WHY. It is not 100% about SPSS, though I see other programs like R don't have this REPEATED thing within the mixed-model context.

Apparently, the concept of "Repeated" in Mixed-Model linear regression is confusingly not similar to "Repeated Measurements" in repeated-measures ANOVA. SPSS asks the user to designate SUBJECT and REPEATED, separately. However, when someone chooses the SUBJECT variable, he already tells the model which observations are repeated within each subject (hence, REPEATED measurements). I know what "REPEATED" means in SPSS MIXED: It means observations that are repeated under different conditions or time points for each subject. For example, the SPSS tutorial says:

Repeated. The variables specified in this list are used to identify repeated observations. For example, a single variable Week might identify the 10 weeks of observations in a medical study, or Month and Day might be used together to identify daily observations over the course of a year.

But doesn't SUBJECT already cover that? In SPSS' own example, SUBJECT tells the model that any measurement recorded at different weeks is for the same Subject, and hence, repeated. This is where I am so confused because that repeated-ness (or correlation) is already told to the model by SUBJECT.

This gets even more confusing when the supposedly "repeated" variable is not of the "time" nature --like the imaginative 'limb length' example I gave above.


Question 2: If SUBJECT and REPEATED are that important, why R doesn't even care about SUBJECT and REPEATED (and model them interchangeably, as if they are the same entity)? Does this invalidate the SPSS' approach to mixed models --i.e., its way of designating separate Subject and Repeated variables?

$\endgroup$
7
  • 3
    $\begingroup$ Not a lot of SPSS users on this site, but if we ignore the software, this question is a duplicate of: stats.stackexchange.com/questions/228800/…. In other words, it's possibly not enough to just say that Subject and Laterality are random effects. These are nested effects, and you need to tell SPSS this so it estimates Subject level variation and then estimates variation due to laterality after. Having a balanced design helps (but amputees in the dataset could imply large differences). $\endgroup$
    – AdamO
    Commented Jan 10 at 19:48
  • $\begingroup$ your question then is not about SPSS, but rather the correct random effect structure to facilitate inspection of morphological differences in a sample of people of a variety of races? $\endgroup$
    – AdamO
    Commented Jan 10 at 19:56
  • $\begingroup$ @AdamO if you double-check, I did talk about nesting ["... and nest them within the SUBJECT variable..."]. Regarding duplication, this is not a duplicated question, given its various aspects, questions, etc. Regarding your answer, thanks that helps, though I would love to receive complete answers to my exact questions. BTW, amputees would be consider missing data in this example. $\endgroup$
    – Vic
    Commented Jan 10 at 19:58
  • 1
    $\begingroup$ If you truly believed left/right were replications, then they don't need any effect at all. This is, of course, not true. The point of specifying left/right effects is because you might believe that if subject A's left arm is longer than their right, their left leg would be longer too. The number of possible permutations of random effects specifications is just too high to deal with. So much so that many analyses fit a variety of models and just pick the one with the best AIC and call it done. $\endgroup$
    – AdamO
    Commented Jan 10 at 20:26
  • 3
    $\begingroup$ Just a practical comment as a former SPSS user who has moved to R: in my experience, these things are only confusing when you try to use SPSS. SPSS "repeated" box is among the most confusing things I've ever encountered. $\endgroup$
    – Sointu
    Commented Jan 11 at 8:17

5 Answers 5

6
+25
$\begingroup$

I have never used SPSS, their documentation is very sparse (nowhere does it show which model is being fit) and I don't own a copy to test, but the terminology is sufficiently similar to SAS that I can wager a guess as to what's going on.

In SAS (and possibly in SPSS), random and repeated can be used alongside one another to define similar models using either, or models that are more complex than what several R implementations allow. Very briefly, the linear mixed model fit by SAS is the following:

$$ \textbf{y} = \textbf{X}\beta + \textbf{Z}\gamma + \epsilon $$ $\textbf{y}$ is your outcome, $\textbf{X}$ the fixed effects design matrix, $\textbf{Z}$ the random effects design. $\beta$ contains the fixed effect parameter estimates, $\gamma$ and $\epsilon$ the random-effect parameters and residual variance. The key point of these last two is the following assumed normal distribution:

$$ \text{E}\begin{bmatrix} \gamma \\ \epsilon\end{bmatrix}=\begin{bmatrix} 0 \\ 0\end{bmatrix},\ \text{Var}\begin{bmatrix} \gamma \\ \epsilon\end{bmatrix}=\begin{bmatrix} \textbf{G} & 0 \\ 0 & \textbf{R}\end{bmatrix} $$

Specifically, they have mean zero and (co)variances $\textbf{G}$ and $\textbf{R}$. The whole point of random and repeated is to specify the structure of $\textbf{G}$ (via $\textbf{Z}$) and $\textbf{R}$ respectively.

Let's start with a longitudinal example because that's where repeated is most intuitive, but it should become clear that there need not be a time component to such models (remember, it only defines the structure of the residual covariance $\textbf{R}$). Suppose we have a small dataset with the following fixed effect design, where the leading letters identify subjects, and we then have an overall intercept and column for a second timepoint:

$$ \textbf{X}=\begin{matrix} \text{a}\\\text{a}\\\text{b}\\\text{b} \end{matrix}\begin{bmatrix}1 & 0 \\ 1 & 1 \\ 1 & 0 \\ 1 & 1\end{bmatrix} $$

If you specify that subject is repeated, the residual covariance will have the following blocked structure (one per level of subject, blanks are zero):

$$ \textbf{R}=\begin{bmatrix}\sigma_0^2 & \sigma_c^2 & & \\ \sigma_c^2 & \sigma_1^2 & & \\ & & \sigma_0^2 & \sigma_c^2 \\ & & \sigma_c^2 & \sigma_1^2 \end{bmatrix} $$

$\textbf{Z}$ and $\textbf{G}$ are undefined and not fit for now. The actual structure and values that these $\sigma^2$ can take can be further specified (e.g. you can set compound symmetry which forces $\sigma_0^2=\sigma_1^2$ or some kind of variance components/banded structure which forces $\sigma_c^2=0$). As an aside, in SAS the only effect of specifying a repeated variable is to set the row order in the $\textbf{R}$ blocks. If you don't, the assumption is that all subjects have the same number of observations (present with missing $\textbf{y}$ if need be) and their order is the same. Failure to do so may lead to e.g. $\sigma_1^2$ being estimated on different timepoints from different subjects instead of always the last.

You can specify the exact same model as random. For this, we make $\textbf{Z}$ equal to $\textbf{X}$ above - you now have to specify an overall and timepoint intercept as random effects in SAS - producing the following (co)variances:

$$ \textbf{G}=\begin{bmatrix}\sigma_0^2 & \sigma_c^2 \\ \sigma_c^2 & \sigma_1^2 \end{bmatrix},\ \textbf{R}=\sigma_r^2 $$

Again, the structure of $\textbf{G}$ can be further specified, but assuming it is the same as before the final response covariance $\textbf{V}=\textbf{ZGZ}^\text{T}+\text{diag}(\textbf{R})$ will be identical to the previous $\textbf{R}$ (where $\textbf{Z}$ and $\textbf{G}$ didn't exist). The actual fitting process is very different and this model is technically quite a bit more complex, but with an unstructured covariance the above $\textbf{G}$ will match within numerical precision to a block of the previous $\textbf{R}$ with $\sigma^2_r$ subtracted from its diagonal.

Returning to the specification of repeated and your limb example: I would assume that the same might happen in SPSS as in SAS. While subject defines the blocking level, repeated matches each observation to a specific row/column in $\textbf{R}$ (just as your random effect design would with $\textbf{G}$). Not doing so might get a left knee matched to a right arm when fitting a single variance parameter. If you don't care about that and you consider limbs exchangeable within subject, you should add a single random intercept at the subject level, because $\textbf{R}$ will still contain one row/column per observation within subject.

To summarize, random and repeated implement two different ways of imposing additional structure on the response covariance. In certain simple cases they can even be made to match (where repeated is more stable & faster so preferred if possible), but random effects are a lot more flexible (e.g. repeated doesn't do slopes, and requires at most one observation per row/column in $\textbf{R}$). For more complex models, such as a mixed effects with additional fixed effect heteroscedasticity, you can even combine them. At least, that's how it works in SAS!

About R

You ask why this is so confusing compared to R implementations. The answer is simple: several of those will let you do either $\textbf{G}$-side (lme4 and many others) or $\textbf{R}$-side effects (e.g. mmrm), but not both. For example, (time | subject) will be identical to random time / subject=subject in SAS if you're using lme4, or to repeated time / subject=subject for mmrm (ignoring covariance structure specification, lme4 only does unstructured I believe).

I recall reading somewhere that nlme might be sufficiently flexible to have both, but I wouldn't know how & assume it will be roughly equally complicated. edit: as mentioned in the comments, the corresponding nlme::lme arguments are random and correlation. glmmTMB was raised as another package that can do both.

Addendum

A few additional questions were raised in the comments, or I neglected to answer them from the OP. All of this still assumes SAS and SPSS behave similarly, which I can't test or find in the documentation for the latter.

I need to know exactly which variables should be put as REPEATED and why?

To restate what repeated asks from your model: instead of treating all observations as coming from a single error distribution (independent & identical), subject defines a block of observations where each observation within that block has a different (structured, no longer necessarily all identical) error distribution. If you don't use repeated or random there will only be a single residual variance parameter, my $\sigma_r^2$ above, and it'll apply to all observations in the input. You've just done basic linear regression.

If you specify repeated without a variable the assumption is that all blocks have the same number of observations in the same order. You can think of this as putting 'observation number within subject' as the repeated variable. If you do specify a repeated variable, observations will be matched based on these. Had we provided a dataset like $\textbf{X}$ in below order to the model, swapping rows 3 & 4, and we did not specify the second column which I'll just call 'class' instead of timepoint or limb or.. as a repeated variable:

$$ \textbf{X}=\begin{matrix} \text{a}\\\text{a}\\\text{b}\\\text{b} \end{matrix}\begin{bmatrix}1 & 0 \\ 1 & 1 \\ 1 & 1 \\ 1 & 0\end{bmatrix} $$

The model will estimate $\sigma_0^2$, the residual variance for the first observation in each subject, from class 0 in subject a and class 1 in subject b. Conversely, $\sigma_1^2$ is estimated from class 1 in subject a and class 0 in subject b. This obviously runs counter to our assumption that the error is still independent & identical within class! Had we provided that repeated variable, the fitting routine would correctly figure out that rows 1 and 4, and rows 2 and 3 are the ones belonging to the same class and match those observations to the corresponding rows/columns of $\textbf{R}$.

if those REPEATED ones should be necessarily nested or not?

I'm not 100% sure what you mean by 'nesting', I understand this as for example limb (arm/leg) being nested in side (left/right) being nested in subject. The model expects you to specify 'subject' as an identifier where different values mean those observations are always assumed to be independent. Specifying nested variables (for subject) is really just a shorthand for expanding dummy variables, as far as I know. The following input data and specifications will lead to the same blocking structure in your model:

Subj  Side  Limb
A     Left  Arm
A     Left  Leg    --> repeat LIMB within SIDE(SUBJ)
A     Right Arm
A     Right Leg


Subj_Side  Limb
A_Left     Arm
A_Left     Leg     --> repeat LIMB within SUBJ_SIDE
A_Right    Arm
A_Right    Leg

Both will result in separate variances for arms/legs, but pool observations from sides and subjects in fitting these.

Another example where you want nested effects is if you have subjects within hospitals, and the subjects start numbering from 1 in each hospital: SUBJECT(HOSPITAL) or subject nested in hospital tells the model that subjects with number 1 aren't actually the same if they also don't share hospital. If all subject numbers are unique across hospitals the non-nested specification gives you the same result.

whether or not those REPEATED ones should be necessarily modeled as random effects or not?

No, most likely not. You can usually turn a repeated model into random as I explained above: repeated is technically simpler but less flexible. Specifying the same design as both repeated and random will lead to confounded variance parameters in your model, which is not what you want if it'll work at all. You can certainly combine repeated and random effects however, I very commonly see models that assume time follows some auto-regressive repeated structure with an additional subject-level random intercept (applying to all timepoints).

SPSS allows a variable (eg. Limb) be designated as REPEATED but not as RANDOM. And in that case, SPSS treats the REPEATED variable as a form of RANDOM effect.

I'm not sure what the limitations are here for SPSS; I would expect repeated not to handle continuous predictors but only intercepts/categorical dummies. Possibly SPSS does not allow you to enter the same effect in both arguments, but you probably don't want that - see above. You are correct that repeated is kind of like random: a model with repeated is the same as a model with a random intercept for every observation within block when using the same subject blocking & specific covariance structures.

Still, one can designate a variable (eg. Limb) as REPEATED, and also as set it as RANDOM at the same time! Or one can designate Limb as REPEATED and RANDOM, and then nest it within SUBJECT!

This runs counter to your previous statement, and goes back to my uncertainty on what you mean by 'nesting': the latter applies to the blocking (i.e. the subject or which observations you consider as independent), not the effects that determine the structure of non-independent observations (repeated/random). I don't want to confuse you more, but it is for example possible to specify a model where you assume limbs within one side follow some covariance structure (the same for each side), and then sides as a whole have another structure within subject. This can only be achieved by using at least one random effect however, just repeated won't get you there.

Another edit: after further clarification by 'nested' you mean "crossed versus nested effects". This is only really relevant for random effects, of which you can have arbitrarily many, and not so much repeated. When you do have multiple random effects you need to think very carefully whether and how they might correlate (going back to the 3-hierarchy example above: does a subject's limb effect depend on its side effect or not?). There can only ever be one level of repeated effect, so that doesn't apply here. Through specification of each covariance structure you can still allow or prevent (certain kinds of) correlation within the effect however, this can go from banded/variance components which has zero correlation, to compound symmetry/auto-regressive which has certain fixed correlations, to unstructured which is 'anything goes' (except negative correlation), and many others.

$\endgroup$
8
  • 3
    $\begingroup$ nlme::lme() allows for both random effects and correlated error terms. In particular, the random argument is used to specify the random-effects components, and the weights and correlation arguments the variance-covariance matrix for the error terms. $\endgroup$ Commented Jan 17 at 10:20
  • 1
    $\begingroup$ @DimitrisRizopoulos Good to know! I've added this info, it seems to match with the random/repeated distinction of SAS (and presumably SPSS). $\endgroup$
    – PBulls
    Commented Jan 17 at 11:10
  • 2
    $\begingroup$ To add another point here, glmmTMB does allow structured covariance matrices, and its approach to R-side correlation structures is to suggest that the user add a "dummy" group that includes the entire data set (or in some cases an observation-level random effect) $\endgroup$
    – Ben Bolker
    Commented Jan 17 at 16:54
  • 1
    $\begingroup$ @Vic I've updated my answer to include your additional questions. The limiting factor is indeed that SPSS documentation is sparse, I'm still going off the assumption that it works in the same way as SAS... which for example doesn't have restrictions on what variables you can put as random. $\endgroup$
    – PBulls
    Commented Jan 19 at 12:19
  • 1
    $\begingroup$ @Vic I see, that nesting distinction doesn't apply to repeated because you can only ever have one repeated effect. As in my very last example you can have an arbitrary number of random effects, and indeed should think carefully about how they might correlate with one another if at all. What you can still do with repeated is impose a covariance structure that may or may not fit correlation between observations within the same block. $\endgroup$
    – PBulls
    Commented Jan 19 at 12:34
4
$\begingroup$

At the end of the day, you would need to know the exact probability model to get the correct result. If you did in fact know that model, then mixed modeling would not be the efficient way to get the answer - a weighted least squares would be where the weight would be given as the inverse of the "known" variance/covariance matrix. This is the Gauss Markov theorem in a nutshell: $\hat{\beta}_{WLS} = \left( X^T W^{-1} X \right) ^{-1} X^T W^{-1} Y$ is BLUE (Best linear unbiased estimator).

Like normal models for slightly non-normal data, mixed models have a certain extent of robustness to model misspecifications. Greater still, is the highly versatile yet highly underutilized Generalized Estimating Equations (GEE). These models make use of a HC - or heteroscedasticity consistent - estimate of the variance which "sandwiches" (literally, it is called a sandwich) the expected and observed Fisher informations based on the empirical residuals to arrive at an estimator which will, with large $n$, always give correct 95% CIs and type 1 error rates. Like LME, the random effects induce a kind of correlation structure which you must express in explicit terms. A random intercept is similar to a compound symmetry correlation structure.

In a mixed model, one's objective is often to identify such random and fixed effects that will yield residuals which are conditionally independent of one another. In the comments, for instance, we discuss "laterality". Suppose you already have fixed or random effects to account for "subject" and "limb". If you believe subjects are perfectly symmetric, then there is no variation in outcome at all - a conditional likelihood approach would require you to drop duplicates and use unilateral measurements only, the variance estimate would be completely on the boundary. On the other "hand" if you already have a reasonable prediction of "hand" length based on the subject and limb's random intercepts, then you must ask whether deviation in left hand is correlated with deviation in the right hand. It seems on the border of our intuition to speculate that, given a subject's traits and the general biometric proportions that a longer than expected left hand would necessarily predict a longer than expected right hand. It may be the opposite - an overlong left side predicts a shorter right side. Interestingly, random effects do not identify clusters of higher variation - it must be lower, you need to use GLS to estimate negative intracluster correlation.

When all is said and done, you can actually conduct tests for random variance components. These tests are not at all trivial, even for very simple problems. In one such example in Diggle Heagerty Liang and Zeger, they show that a likelihood ratio test for the presence of a random intercept has a test statistic which asymptotically follows a $\chi^2_{0.5}$ distribution - a fractional degree of freedom.

My practical experience is that, for the typical sample size requirements, the GEE is a far safer bet when the random effect structure is simply not known.

$\endgroup$
1
  • $\begingroup$ Thanks Adam. Sure I would look into GEE too. BTW, what about the Unstructured covariance matrix, instead of GEE? -- We had a similar discussion about GEE, multilevel mixed models, etc. stats.stackexchange.com/questions/68086/… $\endgroup$
    – Vic
    Commented Jan 13 at 18:51
3
$\begingroup$

Just a few thoughts occurred after reading the nice answers and comments already given.

The repeated in spss can be used (as was already explained ...) to model heteroscedasticity. Below is some code for generating data for two groups. No higher level involved, just one-level data, so no schools, say. Notice that the results for the independent groups t-test with unequal variances gives the same results as mixed does with "repeated":

set seed 1234.
inp pro.
loop #i = 1 to 20.
  compute y = rv.normal(1, 1).
  compute gender = 0.
  end case.
end loop.

loop #i = 1 to 20.
  compute y = rv.normal(2, 5).
  compute gender = 1.
  end case.
end loop.

end file.

end inp pro.
execute.
# Generate a "subject" number. 
compute id = $casenum.
exe.

t-test var y /groups gender(0,1).

enter image description here

In order to use mixed, a "subject" variable has to be mentioned, which is "id" here. Normally, "subject" would be necessary to specify the groups, like schools, but here there are no groups. Yet, a subject must be mentioned.

mixed  y with gender /fixed gender /repeated gender | subject(id) covtype(diag) /print solution.

enter image description here

Gender is the repeated variable here! This is strange, there are no repeated gender observations for the same subject. Repeated simply splits the errors into two independent (because of covtype(diag)) groups, each with its own variance.

Further, notice that in lmer in R a within cluster correlation structure e.g. for correlations between observations from multiple time points of the same person (=subject or cluster) is certainly possible, but implicitly, say. With:

lmer(y ~ (1|id)+time, data=da)

you would implicitly specify a correlation structure, namely the same correlation between any pair of time points considered. With

lmer(y ~ (1+time|id)+time, data=da)

another and more flexible correlation structure is implied, with different correlations between different pairs of time points. So, by using random effects of id and/or time, you create correlations between data within the clusters. This is the reason that mixed models are often used for longitudinal data. However, even more flexible structures can be modeled when using lme e.g. or mixed with random and also repeated.

$\endgroup$
2
  • $\begingroup$ Thanks Ben; upvoted. I know about multilevel modeling; this was not my concern. Please be so kind as to read the body of the question and kindly give your valuable answer about it. Especially my main concern is summarized in the first section of the question. Also if possible, I would much appreciate a central message and/or a more organized answer so that I and future readers know what exactly you are aiming for. For example, you can give a summary in the end. $\endgroup$
    – Vic
    Commented Jan 21 at 23:59
  • $\begingroup$ Hi Ben, thank for this info! Can you clarify about the within-cluster correlation structure in lmer with random slope? Do you mean lmer estimates the within-cluster correlation structure as unstructured or compound symmetry when random slope is included (I've always thought it's the latter, but I'm not sure)? $\endgroup$
    – Sointu
    Commented Jan 22 at 7:16
2
$\begingroup$

This is not an answer, and I think the existing answers are excellent (PBulls' answer really helped me understand things I've never understood before, so thank you!), and I don't think this really adds anything, but Vic (OP) asked me to post what I learned from using SPSS and R for multilevel models and that doesn't fit into a comment. All this is to the best of my understanding which may well have some gaps.

So: if we consider a simple random slope model with one continuous predictor, SPSS's

MIXED y WITH x
  /FIXED= x | SSTYPE(3)
  /RANDOM=INTERCEPT x | SUBJECT(id) COVTYPE(UN).

is identical to R lmer's

mod<-lmer(y ~ x + (x|id), data=data)

When random slope is in the model, lmer uses "unstructured" covariance structure for estimating the variance of random intercept, variance of random slope, and their covariance/correlation, which means that no constraints are imposed on estimating these parameters. In the SPSS syntax, the (UN) in the end denotes this structure and you have to choose it manually in the Random dialogue menu. In lmer, you cannot change this (I think Ben Bolker has presented a way somewhere, but it's quite complex). In SPSS, you can choose from a long list of different variance-covariance structures for random effects if you want. But I think unstructured is pretty good for many (most?) situations because of no constraints.

SPSS "Repeated" box is separate from above. It's meant for longitudinal / repeated measures data to specify a residual covariance structure for your time/repeated variable, or probably also for other clustering variables, even if you use this variable as a fixed predictor (and I think this is what it's often used for). You can only put predictors in Repeated for which you have one (and only one) of each time level per "subject" variable, i.e. like this

id  time
1   1
1   2
1   3
1   4
2   1
2   2
...

I don't understand this procedure very well, but it seems to work in SPSS exactly as PBulls describes it working in SAS. In practice, it gives you covariances of residuals between time points (or the levels of whatever variable you put into the Repeated box) in your outcome, according to the covariance structure you specify.

SPSS says it's default Repeated covariance structure is "Diagonal", but it seems that SPSS doesn't estimate the residual covariance structure at all if you don't specify a "repeated" variable, but leaves it out of the model (I hope that makes sense).

lmer doesn't offer this option at all. Not sure about nlme's lme.


It is common (at least for R users modeling longitudinal data) to put in both random effects of subject and time, as in

model<-lmer(y ~ x + (x|id) + (1|time), data=data)

This is different from SPSS's putting in participant as subject and time as repeated. The equivalent would be putting both subject and time into "subject" box and specifying random effects for both (slope and intercept for id and just intercept for time to match this R code).


Edited to add:

I feel I don't really "get" what exactly is different between a random effect and a repeated effect. I understand conceptually that random intercept gives you cluster-specific intercepts, random slope gives you cluster-specific slopes (plus together they also produce the random effect vcov matrix), and that "repeated effect" gives you repeated variable's residual covariances, but I find it hard to wrap my head around what this actually means in terms of the model. PBulls explained this really well, but as a non-statistician, I still need to process it.


As an additional point, it is my understanding that neither lmer nor SPSS offers the possibility to specify a particular within-cluster correlation structure and I'm unsure what are the defaults of this for SPSS and lmer. I believe nlme package offers this possibility via corStruct command.

$\endgroup$
0
1
$\begingroup$

It must be somewhere already on CV, but with a random (linear) time effect you get

enter image description here

for the covariance between time points $t$ and $s$, their values depending on the way you coded time. $\sigma_{u0j}^2$ is the intercept variance, $\sigma_{u1j}^2$ is the slope-of-time variance and $\sigma_{u01}$ is the covariance of intercept and slope of time. For the variance at time point $t$ you get:

enter image description here

where $\sigma_e^2$ is the variance of the residuals. So, with a random time-slope you model different variances over time, the variances changing as a quadratic function of time.

Adding also a random quadratic/cubic, etc. effect of time would make the model even more flexible. Suppose you have four fixed time-points 1, 2, 3, 4 for each person. If you would then use a linear + quadratic + cubic random time effect, plus a random intercept, lmer would have to estimate (4*3)/2 covariances and 4 variances, and also the residual variance. So, in total lmer would then try to estimate 11 random (co)variances, which is one too many, because in your data you only have 10 observed variances plus covariances. If you could instruct lmer NOT to estimate the residual variance, you would have an unstructured pattern, which may just be estimable. However, with lmer this is not possible, but with glmmTMB you can do this. Meaning that you can estimate the most "rich" or unstructured pattern with random effects. I'm only telling this to explain that without particular software which makes it possible to specify covariance patterns for the residuals $e$ (like mixed with Repeated in spss, or lme or SAS or ...), you still have quite some choices for modeling within-cluster (=person) covariances (or correlations) merely by using random time effects in your model.

Also look at https://stats.oarc.ucla.edu/other/examples/alda/ where models for spss are shown which are discussed in Applied Longitudinal Data Analysis by Singer and Willett. The book discusses the random effect models (spss: /random) and also gls models with NO random effect, but with /repeated. For users who first start working with longitudinal data I would recommend this book.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.