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 ?

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.

  • 1
    I added some more information about my mixed model. Very unfortunately, I have to use SAS so I can use the spatial covariance matrix I mentioned. I won't be able to use your R examples in this case. – Dan Chaltiel Oct 11 at 16:41
  • regarding your answer, which strategy is used by @a_statistician ? – Dan Chaltiel Oct 12 at 12:17
  • @DanChaltiel It's tough to say. You have to be careful using the cov. matrix for the fixed effects in mixed models, there are many ways to calculate them, and to differing extents, their validity "changes" in a local neighborhood. You may be a bit out of your wheelhouse here (if you have a senior statistician, get them on board). A quick glance of PROC MIXED documentation suggests if you set the EMPIRICAL option it fixes the COVB to be more valid, this does the marginal effect I suggested. – AdamO Oct 12 at 13:51

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.

  • 1
    $X$ is not random when calculating CIs. – AdamO Oct 11 at 16:04
  • 1
    Yes. Generally, we consider it as a constant in all process of the modeling . – user158565 Oct 11 at 16:07
  • @a_statistician Great answer, thanks! But re-reading thoroughly my post, it seems I made a mistake: based on my mixed model equation, it is more $a=β1+β3$ and $b=β2$, don't you think ? I guess this may change (1T1) to (T1T) ? Also, could you give a little example of when $X$ is a categorical variable ? I'm very unfamiliar with matrix calculation for now. – Dan Chaltiel Oct 12 at 12:16
  • Yes, $Y = aT + b$ with $a = \beta_1 + \beta_3$ and $b = \beta_2$ means (T, 1, T). For categorical X, we can talk when you meet this situation. – user158565 Oct 13 at 0:33
  • @a_statistician Thanks ! Well actually I'm also meeting this situation (my example is a bit simplified). I thought it would be easy to generify but I was not expecting matrix calculus. Also, is it OK to ignore all $W_i$ in the process (those parameters are of little interest but maybe their variance is important) ? – Dan Chaltiel Oct 15 at 7:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.