knitr::opts_chunk$set(
  error = TRUE,
  collapse = TRUE,
  comment = "#>",
  out.width = "100%"
)
library(testthat)
library(jeksterslabRplots)

Fit the Model

model <- lm(
  wages ~ gender + race + union + education + experience,
  data = jeksterslabRdatarepo::wages
)
yhat <- as.vector(predict(model))
epsilonhat <- as.vector(residuals(model))
tepsilonhat <- as.vector(rstudent(model))
h <- as.vector(hatvalues(model))

Plot the Residuals

.residual.plot(
  yhat = yhat,
  tepsilonhat = tepsilonhat,
  epsilonhat = epsilonhat,
  h = h
)
expect_error(
  object = .residual.plot(
    yhat = yhat,
    tepsilonhat = tepsilonhat,
    epsilonhat = epsilonhat,
    h = h
  ),
  regexp = NA
)


jeksterslabds/jeksterslabRplots documentation built on Aug. 9, 2020, 12:34 a.m.