Commit 6ec27823 authored by Tom Reynkens's avatar Tom Reynkens

Test defaults for input

parent ff45d3e1
Type: Package
Package: smurf
Title: Sparse Multi-Type Regularized Feature Modeling
Version: 0.3.0.9022
Version: 0.3.0.9023
Date: 2018-09-21
Authors@R: c(
person("Tom", "Reynkens", email = "tomreynkens@hotmail.com", role = c("aut", "cre"),
......
......@@ -105,6 +105,7 @@
# offset: Vector containing the offset for the model
# n: Sample size
.check_input_offset <- function(offset, n) {
if (missing(offset)) {
offset <- NULL
}
......
......@@ -40,6 +40,11 @@ test_that("Test input for weights", {
expect_error(glmsmurf(formu, data = rent, family = gaussian(), weights = Inf),
"'weights' must be a vector of finite numbers.",
fixed = TRUE)
# Check default
n <- 10
expect_equal(.check_input_weights(n = n),
rep(1, n))
})
......@@ -74,6 +79,13 @@ test_that("Test input for start", {
expect_error(glmsmurf(formu, data = rent, family = gaussian(), start = Inf),
"'start' must be a vector of finite numbers.",
fixed = TRUE)
# Check default
expect_equal(.check_input_start(y = munich.fit$y, weights = munich.fit$weights,
family = munich.fit$family, n = nrow(rent),
p = length(coef(munich.fit)) - 1, inter = TRUE),
c(munich.fit$family$linkfun(weighted.mean(munich.fit$y, w = munich.fit$weights)),
rep(0, length(coef(munich.fit)) - 1)))
})
......@@ -119,6 +131,11 @@ test_that("Test input for offset", {
expect_error(glmsmurf(formu, data = rent, family = gaussian(), offset = Inf),
"'offset' must be a vector of finite numbers.",
fixed = TRUE)
# Check default
n <- 10
expect_equal(.check_input_offset(n = n),
rep(0, n))
})
......@@ -150,6 +167,10 @@ test_that("Test input for lambda", {
expect_error(glmsmurf(formu, data = rent, family = gaussian(), lambda = Inf),
"'lambda' must be a finite number.",
fixed = TRUE)
# Check default
expect_equal(.check_input_lambda(),
"cv.dev.1se")
})
......
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