tests/testthat/test_.residual.plot.R

#' ---
#' title: "Tests: .residual.plot"
#' author: "Ivan Jacob Agaloos Pesigan"
#' date: "`r Sys.Date()`"
#' output: rmarkdown::html_vignette
#' vignette: >
#'   %\VignetteIndexEntry{Tests: .residual.plot}
#'   %\VignetteEngine{knitr::rmarkdown}
#'   %\VignetteEncoding{UTF-8}
#' ---
#'
#+ include = FALSE
knitr::opts_chunk$set(
  error = TRUE,
  collapse = TRUE,
  comment = "#>",
  out.width = "100%"
)
#'
#'
#'
#+ echo = FALSE
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
#'
#+ eval = FALSE
.residual.plot(
  yhat = yhat,
  tepsilonhat = tepsilonhat,
  epsilonhat = epsilonhat,
  h = h
)
#'
#+ testthat
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.