Closed fabian-s closed 8 years ago
@mayrandy can you have a look at this issue?
Do we have any opportunity to work with matrix calued outcomes within the families? Actually this should be possible as we can also use complex outcomes such as Surv(t, delta)
. I think we need to have specialized families here. Is this worth it?
If we do not have a proper fix we should at least issue a warning or an error if someone tries to use these families.
As far as I can see, this should not be a big issue. We only need to change as.families()
so that it checks if this beta denominator exists as an argument, i.e, something like "bd" %in% names(formals(pdf))
.
If that is the case, we'll have to do
bd <- y[,1] +y[,2]
y <- y[,1]
the rest should be playing around with the arguments so that bd
is included when needed in ngradient
, loss
, mu.initial
, etc.
OK, this should work now with this commit to devel:
library("gamboostLSS")
library("gamlss")
set.seed(123)
n <- 100
x <- rnorm(n)
z <- rnorm(n)
data <- data.frame(y = rbinom(n, p = plogis(x + z), size = 60), x = x, z= z)
data$ymat <- with(data, cbind(success = data$y, fail = 60 - data$y))
m_gamlss <- gamlss(ymat ~ x + z, data = data, family = BB)
Betabin <- as.families(fname="BB")
g1 <- glmboostLSS(ymat ~ x + z, data = data, families = Betabin)
coef(m_gamlss)
#(Intercept) x z
#-0.01365737 1.00916892 0.96522587
coef(g1[1000], off2int = TRUE)$mu
#$mu
#(Intercept) x z
#-0.01324596 1.00947447 0.96550888
# now BI via mboost
g2 <- glmboost(ymat ~x + z, data = data, family = as.families("BI"))
# ignore warning
coef(g2, off2int = TRUE)
#(Intercept) x z
#-0.01368482 1.00917328 0.96521239
Thx.
These are supposed to be called with a 2-column response giving successes & failures, but that doesn't seem to have been implemented yet here.
I have an ugly fix for cases where # of trials is constant for all the data (see below), but that's unsatisfactory for most practical applications, probably.
codefile is here: https://gist.github.com/fabian-s/b952063213f22c31ab9ea99f681a56d7