1
$\begingroup$

Good morning everyone! I have implemented the following lme model in r:

lme_mod<-lme(Value ~ Treatment, random = ~ 1+Treatment| person_ID, method="ML", data=C)

I am analyzing the following residuals: resid(lme_mod).

That ones should be the random effect residuals, right?

Could you write to me a mathematical expression/formula to better explain these residuals?

Thank you very much :)

$\endgroup$
1
  • $\begingroup$ No. resid() extracts the unit residuals, not the random effects. ranef() extracts the random effects $\endgroup$ Commented Jul 8, 2021 at 21:32

1 Answer 1

0
$\begingroup$

I am analyzing the following residuals: resid(lme_mod). That ones should be the random effect residuals, right?

Unfortunately not. resid extracts the residuals - that is the "lower level", or "measurement level" residuals. These are sometimes called "residual error", but care must be taken when referring to "errors" which are part of the data generating process, and "residuals" which are computed from the fitted model and the data. In a sense, the residuals are estimates of the error.

To extract the random effects you would use ranef(lme_mod)

Could you write to me a mathematical expression/formula to better explain these residuals?

The model is:

Value ~ Treatment, random = ~ 1 + Treatment | person_ID

which has the following features:

this has the following features:

  • a global intercept, let us call it $\beta_0$
  • a random intercept, let's call it $u_{0j}$, where $j$ indexes person_IDs
  • fixed effects for Treatment, let's call it $\beta_1$
  • random slopes for Treatment within levels of person_ID, let's call it $u_{1j}$
  • residual error, let us call it $e_{ij}$ for the $i$th observation within the $j$th person_ID

We could write this model as:

$$ Value_{ij} = \beta_0 + u_{0j} + ( \beta_1 + u_{1j}) Treatment + e_{ij} $$

So, to obtain a formula for the residuals, we can start by writing:

$$ e_{ij} = Value_{ij} - \beta_0 - u_{0j} - ( \beta_1 + u_{1j}) Treatment $$

Now, as mentioned, $e_{ij}$ are not the residuals, they are the residual errors, or often just "errors". We compute the residuals after fitting the model and estimating $\beta_1$ and $\beta_0$, and since the model assumes that the random effects are normally distributed about zero (so that their expected value is zero), we have:

$$ \epsilon_{ij} = Value_{ij} - \hat{\beta_0} - \hat{\beta_1} Treatment $$

where $\hat{\beta_0}$ and $\hat{\beta_1}$ are the estimates of $\beta_0$ and $\beta_1$.

$\endgroup$
6
  • $\begingroup$ Thank you very much for your very comprehensive answer. Then the mathematical formula of the residuals extracted with resid(lmwe_model) is as follows: ϵij=Valueij−β0^−β1^Treatment. And you called them "lower level" or "measurement level" residuals, could you clarify how to interpret these residuals? Thank you very much $\endgroup$
    – Bibi
    Commented Jul 12, 2021 at 9:30
  • $\begingroup$ What do you mean "how to interpret these residuals" ? $\endgroup$ Commented Jul 12, 2021 at 11:19
  • $\begingroup$ Usually for the models I consider the residuals as the differences between observed and predicted values of data. But in these LME models maybe its more difficult since there are different kind of residuals. I would ask you how to interpret these specific "lower level" or "measurement level" residuals. Thank you very much for your helpfulness! $\endgroup$
    – Bibi
    Commented Jul 13, 2021 at 7:11
  • $\begingroup$ The unit level residuals are exactly that - the difference between observed and fitted. As for the random effects, these are the offsets from the global estimate (intercept or fixed effect) that each subject/person has. $\endgroup$ Commented Jul 13, 2021 at 12:56
  • $\begingroup$ Does this answer your question ? If so please consider marking it as the accepted answer. If not, please let us know why. Also, if you haven't already, please consider upvoting it. $\endgroup$ Commented Jul 24, 2021 at 12:06

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.