Skip to content

Commit

Permalink
use old interface in Binomial when necessary (see #63)
Browse files Browse the repository at this point in the history
  • Loading branch information
hofnerb committed Jan 20, 2017
1 parent 46a5fbb commit fb25adc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
20 changes: 13 additions & 7 deletions R/family.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,28 @@ link2dist <- function(link, choices = c("logit", "probit"), ...) {
}

Binomial <- function(type = c("adaboost", "glm"),
link = c("logit", "probit", "cloglog", "cauchit", "log")) {
link = c("logit", "probit", "cloglog", "cauchit", "log"), ...) {

type <- match.arg(type)
link <- match.arg(link)
if (type == "adaboost") {
return(Binomial_adaboost(link = link))
return(Binomial_adaboost(link = link, ...))
} else {
return(Binomial_glm(link = link))
}
}

### Binomial
# lfinv <- binomial()$linkinv
Binomial_adaboost <- function(link = c("logit", "probit", "cloglog", "cauchit", "log")) {
Binomial_adaboost <- function(link = c("logit", "probit", "cloglog", "cauchit", "log"), ...) {

link <- match.arg(link)
link <- make.link(link)
tmp <- try(match.arg(link), silent = TRUE)
if (inherits(tmp, "try-error") || link == "probit") {
## use old interface if link is not one of the above (i.e. a distribution)
link <- link2dist(link, ...)
} else {
## use new interface otherwise (not working at the moment)
link <- make.link(tmp)
}

biny <- function(y) {
if (!is.factor(y))
Expand Down Expand Up @@ -200,7 +206,7 @@ Binomial_adaboost <- function(link = c("logit", "probit", "cloglog", "cauchit",
rclass = function(f) (f > 0) + 1 ,
check_y = biny,
name = paste("Negative Binomial Likelihood --",
link$name, "Link")))
attr(link, "link"), "Link")))
}

### Additional Binomial family
Expand Down
3 changes: 2 additions & 1 deletion man/Family.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Family(ngradient, loss = NULL, risk = NULL,
AdaExp()
AUC()
Binomial(type = c("adaboost", "glm"),
link = c("logit", "probit", "cloglog", "cauchit", "log"))
link = c("logit", "probit", "cloglog", "cauchit", "log"), ...)
GaussClass()
GaussReg()
Gaussian()
Expand Down Expand Up @@ -87,6 +87,7 @@ Cindex(sigma = 0.1, ipcw = 1)
(non-negative) interger weights \code{"case"}, or no weights are
allowed \code{"none"}.}
\item{name}{ a character giving the name of the loss function for pretty printing. }
\item{type}{ which parameterization of \code{Binomial} shoule be used?} b
\item{link}{ link function. For possible values see Usage section.}
\item{d}{ delta parameter for Huber loss function. If omitted, it is chosen adaptively.}
\item{tau}{ the quantile or expectile to be estimated, a number strictly between 0 and 1.}
Expand Down

0 comments on commit fb25adc

Please sign in to comment.