tests/testthat/test-path-behavior.R

test_that("regularization path correctly stops if max_variables reached", {

  x <- scale(heart$x)
  y <- heart$y

  fit <- owl(x, y,
             family = "binomial",
             max_variables = 10,
             intercept = FALSE,
             lambda = "bh",
             standardize_features = FALSE)

  n_var <- max(apply(coef(fit), 2, function(x) {
    length(unique(abs(x[x != 0])))
  }))

  expect_lte(n_var, 10)
})

Try the owl package in your browser

Any scripts or data that you put into this service are public.

owl documentation built on Feb. 11, 2020, 5:09 p.m.