This function extracts the residuals from the LME object underlying the RE-EM tree. The residuals depend on the fixed effects (from the tree) plus the estimated contributions of the random effects to the fitted values at grouping levels less or equal to the level given.

1 | ```
residuals.REEMtree(object, level, type, asList, ...)
``` |

`object` |
an object of class |

`level` |
the level of random effects used in creating residuals. Level 0 is fixed effects only; levels increase with the grouping of random effects. Default is the highest level. |

`type` |
optional character string specifying the type of residuals to be used. If |

`asList` |
an optional logical value. If |

`...` |
some methods for this generic require additional arguments; none are used here. |

If the level is a single value, the result is a vector or list (depending on `asList`

) with the residuals. Otherwise, the result is a data frame with columns given by the residuals at different levels.

Rebecca Sela rsela@stern.nyu.edu

Sela, Rebecca J., and Simonoff, Jeffrey S., “RE-EM Trees: A Data Mining Approach for Longitudinal and Clustered Data”, *Machine Learning* (2011).

1 2 3 | ```
data(simpleREEMdata)
REEMresult<-REEMtree(Y~D+t+X, data=simpleREEMdata, random=~1|ID)
residuals(REEMresult)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.