# Variance matrix with equal diagonal entries in PROC MIXED

Is it possible to specify a variance matrix for the random effects in PROC MIXED with the only restriction that the diagonal entries are equal ? I took a look in the help and I have not found, but this seems strange because such a variance structure is rather natural in some applications.

(EDIT) Consider for instance such a dataset:

> dat
Subject Dose   y
1        1    A  10
2        1    A  11
3        1    A  12
4        1    B  30
5        1    B  31
6        1    B  32
7        1    C 100
8        1    C 101
9        1    C 102
10       2    A  11
11       2    A  14
12       2    A  13
13       2    B  33
14       2    B  37
15       2    B  36
16       2    C 105
17       2    C 110
18       2    C 109
19       3    A   9
20       3    A  11
21       3    A  12
22       3    B  30
23       3    B  35
24       3    B  32
25       3    C 115
26       3    C 101
27       3    C 102


and the following model:

PROC MIXED DATA=dat ;
CLASS SUBJECT DOSE ;
MODEL y = DOSE ;
RANDOM DOSE / subject=SUBJECT type=MYMATRIX ;
RUN; QUIT;


I want a matrix "MYMATRIX" with the same variance for each level of the DOSE factor, but not a compound symmetry matrix because the correlation between the means of the levels are different.

(EDIT2) The mathematical meaning of this model is the following one. Denoting by $i$ the index for the dose level and by $j$ the index for the subject, one has $$(y_{ijk} | \mu_{ij}) \sim_{\text{iid}} {\cal N}(\mu_{ij}, \sigma^2_w), \quad k=1, \ldots, 3 \quad \text{ for all } i,j$$ and $$\begin{pmatrix} \mu_{1j} \\ \mu_{2j} \\ \mu_{3j} \end{pmatrix} \sim_{\text{iid}} {\cal N}_3 \left( \begin{pmatrix} \mu_1 \\ \mu_2 \\ \mu_3 \end{pmatrix}, G \right), \quad j=1, \ldots, 3$$ The diagonal entries of the $G$ matrix are the between variances for each level of the dose. I want $G$ to be of the form $$G=\begin{pmatrix} \sigma^2_b & \sigma_{12} & \sigma_{13} \\ \sigma_{12} & \sigma^2_b & \sigma_{23} \\ \sigma_{13} & \sigma_{23} & \sigma^2_b \end{pmatrix}$$

• Do you mean you have several random effects and that you assume all of them to have the same variance? – ocram Jun 21 '12 at 15:49
• @ocram I have just added an example – Stéphane Laurent Jun 21 '12 at 20:43
• What's the motivation for doing this? If you constrain the diagonal of the covariance matrix to be the same, the off diagonal is no longer a correlation/covariance anymore. – AdamO Jun 21 '12 at 21:01
• You're wrong AdamO. For example the identity matrix is such a matrix. The motivation is that there is a physical interpretation of the equality of the between variances. – Stéphane Laurent Jun 22 '12 at 4:40
• Is there no update to this question? I am having exactly the same problem. – user38429 Feb 3 '14 at 10:23

If I do understand your model, you have a random dose effect for each subject:

$$\gamma = \left( \begin{array}{c} \gamma_{1A} \\ \gamma_{1B} \\ \gamma_{1C} \\ \gamma_{2A} \\ \gamma_{2B} \\ \gamma_{2C} \\ \gamma_{3A} \\ \gamma_{3B} \\ \gamma_{3C} \\ \end{array} \right),$$ and $G = \textrm{Var}(\gamma)$ has a block-diagonal structure with identical blocks over subjects: $$G = \left( \begin{array}{ccc} \star & \star & \star & 0 & 0 & 0 & 0 & 0 & 0 \\ \star & \star & \star & 0 & 0 & 0 & 0 & 0 & 0 \\ \star & \star & \star & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & \star & \star & \star & 0 & 0 & 0 \\ 0 & 0 & 0 & \star & \star & \star & 0 & 0 & 0 \\ 0 & 0 & 0 & \star & \star & \star & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & \star & \star & \star \\ 0 & 0 & 0 & 0 & 0 & 0 & \star & \star & \star \\ 0 & 0 & 0 & 0 & 0 & 0 & \star & \star & \star \end{array} \right).$$

Now, the type option specifies the covariance structure of each block. If you specify type=vc (default) then each block will have the form $$\left( \begin{array}{ccc} \star & \star & \star \\ \star & \star & \star \\ \star & \star & \star \end{array} \right) = \left( \begin{array}{ccc} \sigma_{_{G}}^{2} & 0 & 0 \\ 0 & \sigma_{_{G}}^{2} & 0 \\ 0 & 0 & \sigma_{_{G}}^{2} \end{array} \right),$$ where $\sigma_{_{G}}^{2}$ is the single parameter of $G$ to be estimated. If you specify type=toep then $$\left( \begin{array}{ccc} \star & \star & \star \\ \star & \star & \star \\ \star & \star & \star \end{array} \right) = \sigma_{_{G}}^{2} \left( \begin{array}{ccc} 1 & \rho_1 & \rho_2 \\ \rho_1 & 1 & \rho_1 \\ \rho_2 & \rho_1 & 1 \end{array} \right),$$ and now there are three parameters in $G$ to be estimated.



If this does not fit your requirement, then you might want to have a look at the group option: all observations having the same level of the group effect have the same covariance parameters.

• Thank you. In regards to your PS, you're wrong. I will edit my post to make it clearer. The Toeplitz matrix is not appropriate because of $\sigma_{12}=\sigma_{23}$. – Stéphane Laurent Jun 22 '12 at 7:00
• Indeed, the Toeplitz does not fully fit what you want. But is sigma12=sigma23 totally unreasonable? Otherwise, I am afraid you have to go to 'type=un' which is a little bit more general than your G matrix... – ocram Jun 22 '12 at 7:31
• Another motivation for the equality of the diagonal variances is that I assume $y = \log x$ and then taking the exponential of some confidence bounds for $\mu_1-\mu_2$ gives a confidence interval about the ratio of the means of the $x$ response. This is not true without assuming equality of variances. – Stéphane Laurent Jun 22 '12 at 7:35
• Indeed it is not totally unreasonable to assume $\sigma_{12}=\sigma_{23}$. This is what I will do because this is the best available option. But my post is about a way to relax this assumption. – Stéphane Laurent Jun 22 '12 at 9:23
• @Stéphane Laurent: support.sas.com/documentation/cdl/en/statug/63962/HTML/default/… – ocram Jun 22 '12 at 9:46