Skip to content

Commit

Permalink
Adding some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mayrandy committed Sep 16, 2016
1 parent 32f0e6d commit 0d94a46
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/bugfixes.R
Expand Up @@ -29,7 +29,7 @@ stopifnot(all.equal(selected(model),
list(mu = mboost::selected(model[[1]]),
sigma = mboost::selected(model[[2]]))))

# If the families argument is not specified explicitly in mboostLSSone gets an
# If the families argument is not specified explicitly in mboostLSS one gets an
# error in cvrisk.mboostLSS() (spotted by Almond Stöcker).
# (https://github.com/boost-R/gamboostLSS/issues/9)
set.seed(1907)
Expand Down Expand Up @@ -67,4 +67,4 @@ m4 <- glmboost(ymat ~ x + z, data = data, family = as.families("BI"))
round(data.frame(BB_gamlss = coef(m1),
BI_gamlss = coef(m2),
BB_gamboostLSS = coef(m3, off2int = TRUE, parameter = "mu"),
BI_gamboostLSS = coef(m4, off2int = TRUE, parameter = "mu")), 3)
BI_gamboostLSS = coef(m4, off2int = TRUE)), 3)
55 changes: 55 additions & 0 deletions tests/regtest-families.R
Expand Up @@ -57,6 +57,61 @@ model <- glmboostLSS(y ~ x1 + x2, families = StudentTLSS(mu = res[1], sigma =
model[100]
coef(model)

### check as families

### Gaussian: two different ways
model <- glmboostLSS(y ~ x1 + x2, families = as.families("NO"),
data = data,
control = boost_control(mstop = 10), center = TRUE)

model2 <- glmboostLSS(y ~ x1 + x2, families = GaussianLSS(),
data = data,
control = boost_control(mstop = 10), center = TRUE)

coef(model, off2int = TRUE) # as.families("NO")
coef(model2, off2int = TRUE) # GaussianLSS()

### change link function inside as.families()
model2 <- glmboostLSS(abs(y) ~ x1 + x2, families = as.families("NO", mu.link = "log"),
data = data,
control = boost_control(mstop = 10), center = TRUE)
coef(model2)


model3 <- glmboostLSS(abs(y)/(max(y)+.01) ~ x1 + x2, families = as.families("BE", mu.link = "logit",
sigma.link = "log"),
data = data,
control = boost_control(mstop = 10), center = TRUE)
coef(model3)


model4 <- glmboostLSS(y ~ x1 + x2, families = as.families("TF", mu.link = "identity",
sigma.link = "log",
nu.link = "log"),
data = data,
control = boost_control(mstop = 10), center = TRUE)
coef(model4)

### Additionally use stabilization

model4 <- glmboostLSS(y ~ x1 + x2, families = as.families("TF", mu.link = "identity",
sigma.link = "log",
nu.link = "log",
stabilization = "L2"),
data = data,
control = boost_control(mstop = 10), center = TRUE)
coef(model4)


model4 <- glmboostLSS(y ~ x1 + x2, families = as.families("TF", mu.link = "identity",
sigma.link = "log",
nu.link = "log",
stabilization = "MAD"),
data = data,
control = boost_control(mstop = 10), center = TRUE)
coef(model4)


### check survival families

x1 <- runif(1000)
Expand Down

0 comments on commit 0d94a46

Please sign in to comment.