```
# NOT RUN {
## load data and fit model
data("Mandible", package = "lmtest")
fm <- lm(length ~ age, data = Mandible, subset=(age <= 28))
## the following commands lead to the same tests:
summary(fm)
(ct <- coeftest(fm))
## a z test (instead of a t test) can be performed by
coeftest(fm, df = Inf)
## corresponding confidence intervals
confint(ct)
coefci(fm)
## which in this simple case is equivalent to
confint(fm)
## extract further model information either from
## the original model or from the coeftest output
nobs(fm)
nobs(ct)
logLik(fm)
logLik(ct)
AIC(fm, ct)
BIC(fm, ct)
if(require("sandwich")) {
## a different covariance matrix can be also used:
(ct <- coeftest(fm, df = Inf, vcov = vcovHC))
## the corresponding confidence interval can be computed either as
confint(ct)
## or based on the original model
coefci(fm, df = Inf, vcov = vcovHC)
## note that the degrees of freedom _actually used_ can be extracted
df.residual(ct)
## which differ here from
df.residual(fm)
## vcov can also be supplied as a function with additional arguments
coeftest(fm, df = Inf, vcov = vcovHC, type = "HC0")
## or as a matrix
coeftest(fm, df = Inf, vcov = vcovHC(fm, type = "HC0"))
}
# }
```

Run the code above in your browser using DataLab