How to calculate the confidence interval of a line based on its coefficients? I fitted a mixed model as following:
$Y = \beta_0 + \beta_1 T + \beta_2 X + \beta_3 X T + \beta_iW_i$
$T$ is time, $X$ is my variable of interest and $W_i$ are various confounding variables. I also used a specific covariance matrix to modelise the random effect of time (Sp(POW) from SAS).
I want to summarise my data into a regression line of the type.
$Y = aT + b$
with $a = \beta_1 + \beta_3$ and $b = \beta_2$.
Since my betas are estimations and thus random variables, they come along with errors and even their own confidence intervals.
How can I get the CI of $Y$ for any $T$, so I can plot my line with a pretty ribbon ?
 A: Should be var(Y) = var(a)*X² + var(b) + 2X cov(a,b)
cov(a,b) is the covariance between a and b. Generally, the statistical software will not give you this covariance bt default, and you need to force the software to print it out.
Answer after your changes:

$Y = aT + b$
with $a = \beta_2$ and $b = \beta_1 + \beta_3$.

Then $Y = aT + b = \beta_1 + \beta_3 +\beta_2T = (1, T, 1)(\beta_1, \beta_2, \beta_3)'$
$Var(Y)=(1, T, 1)Cov(\beta_1, \beta_2, \beta_3)(1, T, 1)'$
where $Cov(\beta_1, \beta_2, \beta_3)$ is the variance-covariance matrix of estimated fixed effect. You can get it by adding option COVB in MODEL statement in PROC MIXED.
Then you can use PROC IML to perform the matrix calculation to get $Var(Y)$, then se of $Y$, then CI of $Y$ and, finally get a graph.
A: There are many confidence intervals you could draw around the range of fitted effects for $Y$ in a mixed model. I'll note two.
You can draw the marginal effect: To do this, ditch the mixed model and fit a GEE instead. Use the vcovHC function from the sandwich library instead to increase the magnitude of standard error of the conditional mean. Plot the line as you've described.
You can draw the conditional effect. If you have a random intercept model (the simplest type), you can obtain the conditional variance of the $Y$ response for a fixed exposure profile (X) and random effect provided the assumption of independence between the random effect and exposure is met. You would do this by extracting the residual variance from the $Y$ as you say. Look into lme4 documentation for details on doing that.
More complex growth models need a bit more thought and specification to get a useful answer.
