Data is partitioned according to the levels of the grouping factor g and individual lm fits are obtained for each data partition, using the model defined in object.

lmList(object, data, level, subset, na.action = na.fail,
       pool = TRUE, warn.lm = TRUE)

# S3 method for class 'formula'
lmList(object, data, level, subset, na.action = na.fail,
       pool = TRUE, warn.lm = TRUE)

# S3 method for class 'lmList'
update(object, formula., ..., evaluate = TRUE)
# S3 method for class 'lmList'
print(x, pool, ...)

Arguments

object

For lmList, either a linear formula object of the form y ~ x1+...+xn | g or a groupedData object. In the formula object, y represents the response, x1,...,xn the covariates, and g the grouping factor specifying the partitioning of the data according to which different lm fits should be performed. The grouping factor g may be omitted from the formula, in which case the grouping structure will be obtained from data, which must inherit from class groupedData. The method function lmList.groupedData is documented separately. For the method update.lmList, object is an object inheriting from class lmList.

formula

(used in update.lmList only) a two-sided linear formula with the common model for the individuals lm fits.

formula.

Changes to the formula – see update.formula for details.

data

a data frame in which to interpret the variables named in object.

level

an optional integer specifying the level of grouping to be used when multiple nested levels of grouping are present.

subset

an optional expression indicating which subset of the rows of data should be used in the fit. This can be a logical vector, or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default.

na.action

a function that indicates what should happen when the data contain NAs. The default action (na.fail) causes lmList to print an error message and terminate if there are any incomplete observations.

pool

an optional logical value indicating whether a pooled estimate of the residual standard error should be used in calculations of standard deviations or standard errors for summaries.

warn.lm

logical indicating if lm() errors (all of which are caught by tryCatch) should be signalled as a “summarizing” warning.

x

an object inheriting from class lmList to be printed.

...

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

evaluate

If TRUE evaluate the new call else return the call.

Value

a list of lm objects with as many components as the number of groups defined by the grouping factor. Generic functions such as coef, fixed.effects, lme, pairs, plot, predict, random.effects, summary, and update have methods that can be applied to an lmList object.

References

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

Examples

fm1 <- lmList(distance ~ age | Subject, Orthodont)
summary(fm1)
#> Call:
#>   Model: distance ~ age | Subject 
#>    Data: Orthodont 
#> 
#> Coefficients:
#>    (Intercept) 
#>     Estimate Std. Error   t value     Pr(>|t|)
#> M16    16.95   3.288173 5.1548379 3.695247e-06
#> M05    13.65   3.288173 4.1512411 1.181678e-04
#> M02    14.85   3.288173 4.5161854 3.458934e-05
#> M11    20.05   3.288173 6.0976106 1.188838e-07
#> M07    14.95   3.288173 4.5465974 3.116705e-05
#> M08    19.75   3.288173 6.0063745 1.665712e-07
#> M03    16.00   3.288173 4.8659237 1.028488e-05
#> M12    13.25   3.288173 4.0295930 1.762580e-04
#> M13     2.80   3.288173 0.8515366 3.982319e-01
#> M14    19.10   3.288173 5.8086964 3.449588e-07
#> M09    14.40   3.288173 4.3793313 5.509579e-05
#> M15    13.50   3.288173 4.1056231 1.373664e-04
#> M06    18.95   3.288173 5.7630783 4.078189e-07
#> M04    24.70   3.288173 7.5117696 6.081644e-10
#> M01    17.30   3.288173 5.2612799 2.523621e-06
#> M10    21.25   3.288173 6.4625549 3.065505e-08
#> F10    13.55   3.288173 4.1208291 1.306536e-04
#> F09    18.10   3.288173 5.5045761 1.047769e-06
#> F06    17.00   3.288173 5.1700439 3.499774e-06
#> F01    17.25   3.288173 5.2460739 2.665260e-06
#> F05    19.60   3.288173 5.9607565 1.971127e-07
#> F07    16.95   3.288173 5.1548379 3.695247e-06
#> F02    14.20   3.288173 4.3185072 6.763806e-05
#> F08    21.45   3.288173 6.5233789 2.443813e-08
#> F03    14.40   3.288173 4.3793313 5.509579e-05
#> F04    19.65   3.288173 5.9759625 1.863600e-07
#> F11    18.95   3.288173 5.7630783 4.078189e-07
#>    age 
#>     Estimate Std. Error   t value     Pr(>|t|)
#> M16    0.550  0.2929338 1.8775576 6.584707e-02
#> M05    0.850  0.2929338 2.9016799 5.361639e-03
#> M02    0.775  0.2929338 2.6456493 1.065760e-02
#> M11    0.325  0.2929338 1.1094659 2.721458e-01
#> M07    0.800  0.2929338 2.7309929 8.511442e-03
#> M08    0.375  0.2929338 1.2801529 2.059634e-01
#> M03    0.750  0.2929338 2.5603058 1.328807e-02
#> M12    1.000  0.2929338 3.4137411 1.222240e-03
#> M13    1.950  0.2929338 6.6567951 1.485652e-08
#> M14    0.525  0.2929338 1.7922141 7.870160e-02
#> M09    0.975  0.2929338 3.3283976 1.577941e-03
#> M15    1.125  0.2929338 3.8404587 3.247135e-04
#> M06    0.675  0.2929338 2.3042752 2.508117e-02
#> M04    0.175  0.2929338 0.5974047 5.527342e-01
#> M01    0.950  0.2929338 3.2430540 2.030113e-03
#> M10    0.750  0.2929338 2.5603058 1.328807e-02
#> F10    0.450  0.2929338 1.5361835 1.303325e-01
#> F09    0.275  0.2929338 0.9387788 3.520246e-01
#> F06    0.375  0.2929338 1.2801529 2.059634e-01
#> F01    0.375  0.2929338 1.2801529 2.059634e-01
#> F05    0.275  0.2929338 0.9387788 3.520246e-01
#> F07    0.550  0.2929338 1.8775576 6.584707e-02
#> F02    0.800  0.2929338 2.7309929 8.511442e-03
#> F08    0.175  0.2929338 0.5974047 5.527342e-01
#> F03    0.850  0.2929338 2.9016799 5.361639e-03
#> F04    0.475  0.2929338 1.6215270 1.107298e-01
#> F11    0.675  0.2929338 2.3042752 2.508117e-02
#> 
#> Residual standard error: 1.31004 on 54 degrees of freedom
#>