Assess how much of the error in prediction is due to lack of model fit.

ols_pure_error_anova(model, ...)

## Arguments

model |
An object of class `lm` . |

... |
Other parameters. |

## Value

`ols_pure_error_anova`

returns an object of class
`"ols_pure_error_anova"`

. An object of class `"ols_pure_error_anova"`

is a
list containing the following components:

lackoffitlack of fit sum of squares

pure_errorpure error sum of squares

rssregression sum of squares

esserror sum of squares

totaltotal sum of squares

rmsregression mean square

emserror mean square

lmslack of fit mean square

pmspure error mean square

rff statistic

lflack of fit f statistic

prp-value of f statistic

plp-value pf lack of fit f statistic

mpredtibble containing data for the response and predictor of the `model`

df_rssregression sum of squares degrees of freedom

df_esserror sum of squares degrees of freedom

df_loflack of fit degrees of freedom

df_errorpure error degrees of freedom

finaldata.frame; contains computed values used for the lack of fit f test

respcharacter vector; name of `response variable`

predscharacter vector; name of `predictor variable`

## Details

The residual sum of squares resulting from a regression can be decomposed
into 2 components:

Due to lack of fit

Due to random variation

If most of the error is due to lack of fit and not just random error, the
model should be discarded and a new model must be built.

## Note

The lack of fit F test works only with simple linear regression.
Moreover, it is important that the data contains repeat observations i.e.
replicates for at least one of the values of the predictor x. This
test generally only applies to datasets with plenty of replicates.

## References

Kutner, MH, Nachtscheim CJ, Neter J and Li W., 2004, Applied Linear Statistical Models (5th edition).
Chicago, IL., McGraw Hill/Irwin.

## Examples

model <- lm(mpg ~ disp, data = mtcars)
ols_pure_error_anova(model)

#> Lack of Fit F Test
#> -----------------
#> Response : mpg
#> Predictor: disp
#>
#> Analysis of Variance Table
#> ----------------------------------------------------------------------
#> DF Sum Sq Mean Sq F Value Pr(>F)
#> ----------------------------------------------------------------------
#> disp 1 808.8885 808.8885 314.0095 1.934413e-17
#> Residual 30 317.1587 10.57196
#> Lack of fit 25 304.2787 12.17115 4.724824 0.04563623
#> Pure Error 5 12.88 2.576
#> ----------------------------------------------------------------------