Compare increase rate over time 2 groups If you have two groups lets say Y any Z that change over "time", how do you compare if the increase rate of x and y over time is same or not. How would i set this up in R
 A: A naive approach to this question, possibly a motivating example for the subject of time series, is to linearly model the effect of time in both variables, $Y$ and $Z$. If we specify that the observed outcome of these variables is so that:
\begin{array}{c}
E[Y(t)|t] = \beta_0 + \beta_1 t \\
E[Z(t)|t] = \gamma_0 + \gamma_1 t 
\end{array}
you can arrange the data in a stacked (long) format with an indicator ($i$) of which variable is observed at that time with a single outcome variable, $U$.
t i U
1 0 34.3
1 1 36.5
2 0 39.0
2 1 37.4
3 0 40.1
3 1 40.4
4 0 40.6
4 1 44.0

and setting up a regression model for the outcome, the growth rate can be explicitly estimated using a stratified model.
$E \left( U(t) | i, t \right) = \delta_0 + \delta_1 i + \delta_2t$
so that $\delta_1$ is the difference in means between $Y$ and $Z$ at time 0. But we have assumed the growth rate is the same between the two variables, and that is given by $\delta_2$ which is interpreted as an expected difference in outcome for a unit difference in time.
Compare that model with the saturated model with interaction terms:
$E \left( U(t) | i, t \right) = \delta_0 + \delta_1 i + \delta_2 t + \delta_3 i t$
Now $\delta_3$ is a measure of the difference in time based growth between $Z$ and $Y$. Under the null hypothesis $\delta_3=0$ because there is no difference in growth rate over time. By testing this hypothesis using the stratified (nested) model using a likelihood ratio test, you have a simple, naive approach to testing whether there is a difference in growth rates.
