# Fitting a Linear Mixed Effects Model

Suppose I have data on 4 units, $$X_i(t_{ij})$$, for $$i= 1,2,3,4$$ and $$j = 1,\dots,10$$. That is, I have 10 observations for each unit.

The observations for unit $$i$$ were recorded at times $$t_{i,1}, \dots, t_{i,10}$$, and the time between recordings is constant.

I do not know what $$t_{ij}$$ are, but I know the times between recordings is constant. I could choose $$t_{ij}$$ for $$i = 1,2,3,4$$ to be $$1,\dots,10$$ or $$0,\dots, 9$$, or any other equally spaced sequence of length 10, but which do I pick?

The model I am considering is

$$\begin{equation} X_i(t_{ij}) = \eta + Z_i(t_{ij})w_i + \epsilon_{ij}, \end{equation}$$

where $$\eta$$ is the mean, $$Z_i(t_{ij}) = [1, \log(t_{ij})]$$, $$w_i = (w_{0i}, w_{1i})' \sim N(0, \Sigma_w)$$, $$\epsilon_{ij} \sim N(0, \sigma^2)$$, and

$$\begin{equation} \Sigma = \begin{bmatrix} \sigma_1^2 & \rho\sigma_1\sigma_2 \\ \rho\sigma_1\sigma_2 & \sigma_2^2 \end{bmatrix}. \end{equation}$$

In this example, I could not choose $$t = 0, \dots, 9$$ because of the $$\log(t)$$ term. In this example $$t$$ is chosen to be $$1, \dots, 10$$ for each unit. I can see why this was chosen, but could another sequence be chosen? If not why not?

If you consider a small dummy example; here $$x$$ is the data for each unit concatenated into one vector; unit represents which unit the data came from; and tt and tt2 are two different time sequences:

#Data
x = c(1.4806073,  1.2493809,  1.1612487,  1.1252604,  1.0057363,  0.9315882,  0.9091001,  0.8586410,  0.8297411,
0.7403425,  0.9725159,  1.1334336,  1.0876942,  1.0984994,  1.0607115,  1.0308212,  1.0824410,  1.0957307,
1.2664261,  1.1936734,  0.9573181,  1.2820057,  1.3489198,  1.4074968,  1.5751318,  1.6024103,  1.6203662,
1.6487979,  1.6294239,  1.7369618, -0.1207026, -0.1475024, -0.1562043, -0.2044265, -0.2118383, -0.2406047,
-0.1813440, -0.2671027, -0.3339175, -0.2192462)

tt = rep(1:10,4)
tt2 = tt + 20

unit = rep(1:4, each = 10)

DF1 = data.frame(unit, tt, x)
DF2 = data.frame(unit, tt2, x)

#Fits a linear mixed effects model
lme1=lme(x ~ 1, data = DF1, random = ~ I(log(tt))|unit)
lme2=lme(x ~ 1, data = DF2, random = ~ I(log(tt2))|unit)

mean((lme1$$fitted[,2] - lme2$$fitted[,2])^2)
#0.00165495


I was hoping that the two models would produce the same fitted values, but they do not. This means that the choice of sequence makes a difference when fitting the model.

One reason I ask is because I have seen similar models where the author has started counting from 0; and sometimes I have seen authors count from 1.

The difference between using tt and tt2 in the random effects is that you are log transforming them, and the logarithm is not a linear function. Hence, tt and tt2 are equidistant in the original scale but when you apply the logarithmic transformation the distance between the two sequences is not the same anymore. If you compare the models
lme1b <- lme(x ~ 1, data = DF1, random = ~ tt | unit)

lme2b <- lme(x ~ 1, data = DF2, random = ~ tt2 | unit)