Commit ec0ffef5 authored by Tom Reynkens's avatar Tom Reynkens

Add extra tests for residuals function

parent 3d3d6af8
Type: Package
Package: smurf
Title: Sparse Multi-Type Regularized Feature Modeling
Version: 0.3.0.9020
Version: 0.3.0.9021
Date: 2018-09-20
Authors@R: c(
person("Tom", "Reynkens", email = "tomreynkens@hotmail.com", role = c("aut", "cre"),
......
......@@ -96,7 +96,7 @@ resid_reest.glmsmurf <- residuals_reest.glmsmurf
# Auxiliary function for residuals of estimated model (reest=FALSE) or re-estimated model (reest=TRUE)
.residuals.glmsmurf.aux <- function(object, type = c("deviance", "pearson", "working", "response", "partial"),
reest = FALSE, ...) {
reest = FALSE, ...) {
# Get type of residuals
type <- match.arg(type)
......
......@@ -428,6 +428,30 @@ test_that("Test residuals and residuals_reest", {
expect_equal(residuals_reest(munich.fit),
resid_reest(munich.fit))
# Check without y
munich.fit.noy <- munich.fit
munich.fit.noy$y <- NULL
expect_equal(residuals(munich.fit.noy, type = "deviance"),
resid.dev)
expect_equal(residuals(munich.fit.noy, type = "partial"),
resid.par)
expect_equal(residuals_reest(munich.fit.noy, type = "deviance"),
resid.dev.reest)
expect_equal(residuals_reest(munich.fit.noy, type = "partial"),
resid.par.reest)
# Check with df.residual = 0
munich.fit.noy$df.residual <- 0
expect_equal(as.numeric(residuals(munich.fit.noy, type = "deviance")),
rep(0, length(fitted(munich.fit.noy))))
expect_equal(as.numeric(residuals_reest(munich.fit.noy, type = "deviance")),
rep(0, length(fitted_reest(munich.fit.noy))))
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment