bg {AFR} | R Documentation |

BG test is used to test for autocorrelation in the errors of a regression model

```
bg(
model,
order = 1,
order.by = NULL,
type = c("Chisq", "F"),
data = list(),
fill = 0
)
```

`model` |
is a (generalized)linear regression model |

`order` |
integer. maximal order of serial correlation to be tested. |

`order.by` |
Either a vector z or a formula with a single explanatory variable like ~ z |

`type` |
the type of test statistic to be returned |

`data` |
an optional data frame containing the variables in the model |

`fill` |
starting values for the lagged residuals in the auxiliary regression. By default 0 but can also be set to NA. |

Mitchel, D. and Zeileis, A. Published 2021-11-07. lmtest package

```
model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ)
bg(model)
```

[Package *AFR* version 0.2.1 Index]