#' ---
#' 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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.