The fitted values at level \(i\) are obtained by adding together the population fitted values (based only on the fixed effects estimates) and the estimated contributions of the random effects to the fitted values at grouping levels less or equal to \(i\). The resulting values estimate the best linear unbiased predictions (BLUPs) at level \(i\).

# S3 method for class 'lme'
fitted(object, level, asList, ...)

Arguments

object

an object inheriting from class "lme", representing a fitted linear mixed-effects model.

level

an optional integer vector giving the level(s) of grouping to be used in extracting the fitted values from object. Level values increase from outermost to innermost grouping, with level zero corresponding to the population fitted values. Defaults to the highest or innermost level of grouping.

asList

an optional logical value. If TRUE and a single value is given in level, the returned object is a list with the fitted values split by groups; else the returned value is either a vector or a data frame, according to the length of level. Defaults to FALSE.

...

some methods for this generic require additional arguments. None are used in this method.

Value

If a single level of grouping is specified in level, the returned value is either a list with the fitted values split by groups (asList = TRUE) or a vector with the fitted values (asList = FALSE); else, when multiple grouping levels are specified in level, the returned object is a data frame with columns given by the fitted values at different levels and the grouping factors. For a vector or data frame result the napredict method is applied.

References

Bates, D.M. and Pinheiro, J.C. (1998) "Computational methods for multilevel models" available in PostScript or PDF formats at http://nlme.stat.wisc.edu/pub/NLME/

Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer, esp. pp. 235, 397.

Author

José Pinheiro and Douglas Bates bates@stat.wisc.edu

See also

Examples

fm1 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
fitted(fm1, level = 0:1)
#>        fixed  Subject
#> 1   22.98819 25.39237
#> 2   24.30856 26.71274
#> 3   25.62894 28.03311
#> 4   26.94931 29.35348
#> 5   22.98819 21.61052
#> 6   24.30856 22.93089
#> 7   25.62894 24.25126
#> 8   26.94931 25.57163
#> 9   22.98819 22.36689
#> 10  24.30856 23.68726
#> 11  25.62894 25.00763
#> 12  26.94931 26.32800
#> 13  22.98819 24.41990
#> 14  24.30856 25.74027
#> 15  25.62894 27.06064
#> 16  26.94931 28.38101
#> 17  22.98819 21.28636
#> 18  24.30856 22.60673
#> 19  25.62894 23.92710
#> 20  26.94931 25.24747
#> 21  22.98819 24.20379
#> 22  24.30856 25.52416
#> 23  25.62894 26.84453
#> 24  26.94931 28.16490
#> 25  22.98819 21.93468
#> 26  24.30856 23.25505
#> 27  25.62894 24.57542
#> 28  26.94931 25.89579
#> 29  22.98819 22.04273
#> 30  24.30856 23.36310
#> 31  25.62894 24.68347
#> 32  26.94931 26.00384
#> 33  22.98819 23.12326
#> 34  24.30856 24.44363
#> 35  25.62894 25.76400
#> 36  26.94931 27.08437
#> 37  22.98819 26.90511
#> 38  24.30856 28.22548
#> 39  25.62894 29.54585
#> 40  26.94931 30.86622
#> 41  22.98819 21.82663
#> 42  24.30856 23.14700
#> 43  25.62894 24.46737
#> 44  26.94931 25.78774
#> 45  22.98819 22.36689
#> 46  24.30856 23.68726
#> 47  25.62894 25.00763
#> 48  26.94931 26.32800
#> 49  22.98819 22.36689
#> 50  24.30856 23.68726
#> 51  25.62894 25.00763
#> 52  26.94931 26.32800
#> 53  22.98819 22.90715
#> 54  24.30856 24.22753
#> 55  25.62894 25.54790
#> 56  26.94931 26.86827
#> 57  22.98819 23.77158
#> 58  24.30856 25.09195
#> 59  25.62894 26.41232
#> 60  26.94931 27.73269
#> 61  22.98819 21.28636
#> 62  24.30856 22.60673
#> 63  25.62894 23.92710
#> 64  26.94931 25.24747
#> 65  20.66717 19.56700
#> 66  21.98754 20.88737
#> 67  23.30791 22.20774
#> 68  24.62828 23.52811
#> 69  20.66717 20.97168
#> 70  21.98754 22.29205
#> 71  23.30791 23.61243
#> 72  24.62828 24.93280
#> 73  20.66717 21.62000
#> 74  21.98754 22.94037
#> 75  23.30791 24.26074
#> 76  24.62828 25.58111
#> 77  20.66717 22.59248
#> 78  21.98754 23.91285
#> 79  23.30791 25.23322
#> 80  24.62828 26.55359
#> 81  20.66717 20.64753
#> 82  21.98754 21.96790
#> 83  23.30791 23.28827
#> 84  24.62828 24.60864
#> 85  20.66717 19.35089
#> 86  21.98754 20.67126
#> 87  23.30791 21.99163
#> 88  24.62828 23.31200
#> 89  20.66717 20.97168
#> 90  21.98754 22.29205
#> 91  23.30791 23.61243
#> 92  24.62828 24.93280
#> 93  20.66717 21.29584
#> 94  21.98754 22.61621
#> 95  23.30791 23.93658
#> 96  24.62828 25.25695
#> 97  20.66717 19.35089
#> 98  21.98754 20.67126
#> 99  23.30791 21.99163
#> 100 24.62828 23.31200
#> 101 20.66717 17.08178
#> 102 21.98754 18.40215
#> 103 23.30791 19.72252
#> 104 24.62828 21.04289
#> 105 20.66717 23.88911
#> 106 21.98754 25.20948
#> 107 23.30791 26.52985
#> 108 24.62828 27.85022