1
$\begingroup$

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

$\endgroup$
2
  • 1
    $\begingroup$ Are these TS AR, ARMA, ARIMA, etc? there is a function arima in the stats package that will help you set up a time series. Here is a link to a description:. stat.ethz.ch/R-manual/R-patched/library/stats/html/arima.html You'll have to do some work on the time series like look at the ACF and PACF functions to decide what type of time series you're working with. Building different models and looking at the $\sigma^2$ and AIC output for the model will let you know how good a model you've built (the lower the AIC the better). AIC will be an object of the time series you build in ARIMA. $\endgroup$ Apr 19, 2013 at 3:40
  • $\begingroup$ I think I need to use AR(1) or Ar(2) but both of my data Y and Z are positive linear not sideways. for example when i type plot(y~time) and plot(Z~time) the dots go from bottom left corner to top right corner. if I know this what should be my next step $\endgroup$
    – user24534
    Apr 19, 2013 at 3:56

1 Answer 1

2
$\begingroup$

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.

$\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.