tests/testthat/test_path_singboost.R

test_that("Function path_singboost is implemented correctly",{
glmres<-glmboost(Sepal.Length~.,iris)
firis<-as.formula(Sepal.Length~.)
Xiris<-model.matrix(firis,iris)
Diris<-data.frame(Xiris[,-1],iris$Sepal.Length)
expect_error(path.singboost(Diris,m_iter=-2))
expect_error(path.singboost(Diris,m_iter=8.7))
expect_error(path.singboost(Diris,kap=-0.2))
expect_error(path.singboost(Diris,kap=1.1))
expect_error(path.singboost(Diris,M=3.3))
expect_error(path.singboost(Diris,M=-1))
expect_error(path.singboost(Diris,M=200))
ressing<-path.singboost(Diris)
ressing2<-path.singboost(Diris,LS=TRUE)
expect_equal(as.numeric(coef(glmres)[-1]),as.numeric(ressing$Coefficients[-1][ressing$Coefficients[-1]!=0]))
expect_equal(as.numeric(coef(glmres)[-1]),as.numeric(ressing2$Coefficients[-1][ressing2$Coefficients[-1]!=0]))
expect_equal(as.numeric(coef(glmres)[1]+glmres$offset),ressing$Coefficients[1])
expect_equal(as.numeric(coef(glmres)[1]+glmres$offset),ressing2$Coefficients[1])
expect_equal(attributes(varimp(glmres))$self,ressing$Freqs)
expect_equal(attributes(varimp(glmres))$self,ressing2$Freqs)
ressingo<-path.singboost(Diris)
ressingo2<-path.singboost(Diris,LS=TRUE)
expect_equal(ressing[1:3],ressingo[1:3])
expect_equal(ressing2[1:3],ressingo2[1:3])
})

Try the gfboost package in your browser

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

gfboost documentation built on Jan. 7, 2022, 5:06 p.m.