Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

as.families("BEINF") not working #28

Closed
hofnerb opened this issue Jan 9, 2017 · 5 comments
Closed

as.families("BEINF") not working #28

hofnerb opened this issue Jan 9, 2017 · 5 comments
Assignees
Labels

Comments

@hofnerb
Copy link
Member

hofnerb commented Jan 9, 2017

The following code does not work:

library("gamboostLSS")
library("gamlss.dist")
data <- data.frame(x1 = runif(400), x2 = runif(400))
data$y <- with(data, rBEINF(400, mu = range((x1 + x2 - min(x1 + x2) + 0.001) / (diff(range(x1 + x2)) + 0.002)), 
                          sigma = sqrt(x1), nu = 0.1, tau = 0.1))
mod <- gamboostLSS(y ~ x1 + x2, data = data, families = as.families("BEINF"))
# Error in FAM$dldm(y = y, mu = FAM$mu.linkinv(f), sigma = sigma, nu = nu,  : 
#   unused arguments (nu = nu, tau = tau)

The reason can be found in

gamlss.dist::as.gamlss.family("BEINF")$dldm
#  function (y, mu, sigma) 
#  {
#      a <- mu * (1 - sigma^2)/(sigma^2)
#      b <- a * (1 - mu)/mu
#      dldm <- ifelse(((y == 0) | (y == 1)), 0, ((1 - sigma^2)/(sigma^2)) * 
#          (-digamma(a) + digamma(b) + log(y) - log(1 - y)))
#      dldm
#  }

which is a function of mu and sigma only.

How can we fix this for this family (and potentially others)? Is a change in gamlss.dist needed or can we fix this ourselves? Are there other families leading to the same or a similar issue?

@mayrandy, can you have a look at this?

@mayrandy
Copy link
Member

mayrandy commented Jan 9, 2017

Thanks for finding this! This should be a problem for all inflated families, e.g. BEOI():

BEINF()$nopar
[1] 4
 BEOI()$nopar
[1] 3

But their corresponding functions for the derivatives BEOI()$dldm have arguments mu and sigma only which leads to the error.

I think we should be able to fix this in our code, I'll take a look.

@hofnerb
Copy link
Member Author

hofnerb commented Jan 10, 2017 via email

@hofnerb
Copy link
Member Author

hofnerb commented Jan 10, 2017

Thanks a lot!

Perhaps there are even more families with similar properties?
Could check this issue by comparing nopar with the number of parameters in dldm either by simply calling the functions or by computing on

deparse(gamlss.dist::as.gamlss.family("BEINF")$dldm)[1]

for all available families in a loop?

@mayrandy
Copy link
Member

mayrandy commented Feb 2, 2017

OK, all those families have FAM()$type == "Mixed", found that in my own code.

Apparently I had already implemented such cases for 3-parametric families and was only too lazy to do the same also for the 4-paremetric ones. Should be fixed now in "devel".

@hofnerb
Copy link
Member Author

hofnerb commented Feb 5, 2017

Merci :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants