predict.lmList.Rd
If the grouping factor corresponding to object
is included
in newdata
, the data frame is partitioned according to the
grouping factor levels; else, newdata
is repeated for all
lm
components. The predictions and, optionally, the standard
errors for the predictions, are obtained for each lm
component of object
, using the corresponding element of the
partitioned newdata
, and arranged into a list with as many
components as object
, or combined into a single vector or data
frame (if se.fit=TRUE
).
# S3 method for class 'lmList'
predict(object, newdata, subset, pool, asList, se.fit, ...)
an object inheriting from class "lmList"
, representing
a list of lm
objects with a common model.
an optional data frame to be used for obtaining the
predictions. All variables used in the object
model formula
must be present in the data frame. If missing, the same data frame
used to produce object
is used.
an optional character or integer vector naming the
lm
components of object
from which the predictions
are to be extracted. Default is NULL
, in which case all
components are used.
an optional logical value. If TRUE
, the returned
object is a list with the predictions split by groups; else the
returned value is a vector. Defaults to FALSE
.
an optional logical value indicating whether a pooled
estimate of the residual standard error should be used. Default is
attr(object, "pool")
.
an optional logical value indicating whether pointwise
standard errors should be computed along with the
predictions. Default is FALSE
.
some methods for this generic require additional arguments. None are used in this method.
a list with components given by the predictions (and, optionally, the
standard errors for the predictions) from each lm
component of object
, a vector with the predictions from all
lm
components of object
, or a data frame with columns
given by the predictions and their corresponding standard errors.
fm1 <- lmList(distance ~ age | Subject, Orthodont)
predict(fm1, se.fit = TRUE)
#> Subject fit se.fit
#> 1 M16 21.35 1.0960578
#> 2 M16 22.45 0.7175382
#> 3 M16 23.55 0.7175382
#> 4 M16 24.65 1.0960578
#> 5 M05 20.45 1.0960578
#> 6 M05 22.15 0.7175382
#> 7 M05 23.85 0.7175382
#> 8 M05 25.55 1.0960578
#> 9 M02 21.05 1.0960578
#> 10 M02 22.60 0.7175382
#> 11 M02 24.15 0.7175382
#> 12 M02 25.70 1.0960578
#> 13 M11 22.65 1.0960578
#> 14 M11 23.30 0.7175382
#> 15 M11 23.95 0.7175382
#> 16 M11 24.60 1.0960578
#> 17 M07 21.35 1.0960578
#> 18 M07 22.95 0.7175382
#> 19 M07 24.55 0.7175382
#> 20 M07 26.15 1.0960578
#> 21 M08 22.75 1.0960578
#> 22 M08 23.50 0.7175382
#> 23 M08 24.25 0.7175382
#> 24 M08 25.00 1.0960578
#> 25 M03 22.00 1.0960578
#> 26 M03 23.50 0.7175382
#> 27 M03 25.00 0.7175382
#> 28 M03 26.50 1.0960578
#> 29 M12 21.25 1.0960578
#> 30 M12 23.25 0.7175382
#> 31 M12 25.25 0.7175382
#> 32 M12 27.25 1.0960578
#> 33 M13 18.40 1.0960578
#> 34 M13 22.30 0.7175382
#> 35 M13 26.20 0.7175382
#> 36 M13 30.10 1.0960578
#> 37 M14 23.30 1.0960578
#> 38 M14 24.35 0.7175382
#> 39 M14 25.40 0.7175382
#> 40 M14 26.45 1.0960578
#> 41 M09 22.20 1.0960578
#> 42 M09 24.15 0.7175382
#> 43 M09 26.10 0.7175382
#> 44 M09 28.05 1.0960578
#> 45 M15 22.50 1.0960578
#> 46 M15 24.75 0.7175382
#> 47 M15 27.00 0.7175382
#> 48 M15 29.25 1.0960578
#> 49 M06 24.35 1.0960578
#> 50 M06 25.70 0.7175382
#> 51 M06 27.05 0.7175382
#> 52 M06 28.40 1.0960578
#> 53 M04 26.10 1.0960578
#> 54 M04 26.45 0.7175382
#> 55 M04 26.80 0.7175382
#> 56 M04 27.15 1.0960578
#> 57 M01 24.90 1.0960578
#> 58 M01 26.80 0.7175382
#> 59 M01 28.70 0.7175382
#> 60 M01 30.60 1.0960578
#> 61 M10 27.25 1.0960578
#> 62 M10 28.75 0.7175382
#> 63 M10 30.25 0.7175382
#> 64 M10 31.75 1.0960578
#> 65 F10 17.15 1.0960578
#> 66 F10 18.05 0.7175382
#> 67 F10 18.95 0.7175382
#> 68 F10 19.85 1.0960578
#> 69 F09 20.30 1.0960578
#> 70 F09 20.85 0.7175382
#> 71 F09 21.40 0.7175382
#> 72 F09 21.95 1.0960578
#> 73 F06 20.00 1.0960578
#> 74 F06 20.75 0.7175382
#> 75 F06 21.50 0.7175382
#> 76 F06 22.25 1.0960578
#> 77 F01 20.25 1.0960578
#> 78 F01 21.00 0.7175382
#> 79 F01 21.75 0.7175382
#> 80 F01 22.50 1.0960578
#> 81 F05 21.80 1.0960578
#> 82 F05 22.35 0.7175382
#> 83 F05 22.90 0.7175382
#> 84 F05 23.45 1.0960578
#> 85 F07 21.35 1.0960578
#> 86 F07 22.45 0.7175382
#> 87 F07 23.55 0.7175382
#> 88 F07 24.65 1.0960578
#> 89 F02 20.60 1.0960578
#> 90 F02 22.20 0.7175382
#> 91 F02 23.80 0.7175382
#> 92 F02 25.40 1.0960578
#> 93 F08 22.85 1.0960578
#> 94 F08 23.20 0.7175382
#> 95 F08 23.55 0.7175382
#> 96 F08 23.90 1.0960578
#> 97 F03 21.20 1.0960578
#> 98 F03 22.90 0.7175382
#> 99 F03 24.60 0.7175382
#> 100 F03 26.30 1.0960578
#> 101 F04 23.45 1.0960578
#> 102 F04 24.40 0.7175382
#> 103 F04 25.35 0.7175382
#> 104 F04 26.30 1.0960578
#> 105 F11 24.35 1.0960578
#> 106 F11 25.70 0.7175382
#> 107 F11 27.05 0.7175382
#> 108 F11 28.40 1.0960578