LinearRegressionByClass {cheddar} | R Documentation

## Linear regression by class

### Description

Fit linear regressions to node data by class.

### Usage

    LinearRegressionByClass(community, X, Y, class)

### Arguments

`community` | an object of class `Community`.
`X` | Independent variable. A property name that must meet the criteria of the `properties` parameter of `NPS`.
`Y` | Dependent variable. A property name that must meet the criteria of the `properties` parameter of `NPS`.
`class` | The property over which linear regressions are fitted.

### Details

A linear model is fitted through all data points and through each subset of the data given by `class`. A list of `lm` objects is returned. The list will contain `NULL` if it is not possible to fit a linear regression to that class; this will happen for classes that contain just a single node or that contain all or all but one nodes where `X` and/or `Y` is `NA`.

### Value

A `list` of `lm` objects.

### Author(s)

Lawrence Hudson

### See Also

`Community`, `ApplyByClass`, `NPS`, `NvMLinearRegressions`, `lm`

### Examples

    data(TL84)

    # Regressions fitted to log10(Biomass) versus log10(M) data.
    models <- LinearRegressionByClass(TL84, 'Log10M', 'Log10Biomass',
                                      'category')

    # 'all', 'producer', 'invertebrate', 'vert.ecto'
    names(models)

    # Extract slopes and intercepts
    sapply(models, coef)

[Package cheddar version 0.1-633 Index]