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

error when trying brnb for negative binomial #31

Open
cperk opened this issue Jul 19, 2021 · 7 comments
Open

error when trying brnb for negative binomial #31

cperk opened this issue Jul 19, 2021 · 7 comments

Comments

@cperk
Copy link

cperk commented Jul 19, 2021

Hello,

I was excited to find this package to solve my complete separation problem. My count data is overdispersed so need to use the negative binomial family, which I understand is run using brnb(). I keep getting this error: NA/NaN/Inf in foreign function call (arg 1), even though I am specifying all the necessary terms:

salmonella_fm <- production ~ Treat_comboSource_Salinity +Rarity+ Region+Treat_comboTurion_length_num+replanted.x

N_T_6_2020_nbn <- brglm2::brnb(salmonella_fm,
data=turion_harvest_2021_all_gen_initial_turion,link = "log",transformation = "inverse", type = "AS_mean")

I've noticed that the error disappears if I use type="ML" but all other types trigger the error.

Could you please advise?

Thanks!

-Carrie

@ikosmidis
Copy link
Owner

Hi @cperk: thanks for the report. If you share a reproducible example (with data and code) that demonstrates the issue I can investigate. The reprex R package may come in handy. -I

@cperk
Copy link
Author

cperk commented Jul 19, 2021

Thanks!

Here is a reproducible example:

df1 <- data.frame(production=c(15,12,10,9,6,8,9,5,3,3,2,1,0,0,0,0), Treatment_Num=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4), Treatment=c("Fresh","Fresh","Fresh","Fresh","low","low","low","low","med","med","med","med","high","high","high","high"),Genotype=c(1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2), Source_Salinity=c("Fresh","Fresh","Brackish","Brackish","Fresh","Fresh","Brackish","Brackish","Fresh","Fresh","Brackish","Brackish","Fresh","Fresh","Brackish","Brackish"), Days_to_death <- c(500, 500, 500, 500, 400, 350, 300, 500, 200, 202, 260, 280, 150,150,160,140), censored <- c(1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0))


salmonella_fm <- production ~ Treatment
N_T_6_2020_nbn_toy <- brglm2::brnb(salmonella_fm,
                               data=df1,link = "log",transformation = "inverse", type = "AS_mean")

I figured out that it only happens when the fixed effect is categorical; when I use a numeric version of Treatment, the error disappears:

salmonella_fm <- production ~ Treatment_Num
N_T_6_2020_nbn_toy <- brglm2::brnb(salmonella_fm,
                               data=df1,link = "log",transformation = "inverse", type = "AS_mean")

In my real data it wouldn't be appropriate to convert Treatment to numeric, so I would really appreciate it if you could find a solution for using a categorical fixed effect!

@cperk
Copy link
Author

cperk commented Jul 25, 2021

Any update on this?

@ikosmidis
Copy link
Owner

ikosmidis commented Jul 25, 2021

We are investigating the issue you opened. I understand that you may need a resolution quickly, but please note that we cannot guarantee the timeframe of response/resolution.

@cperk
Copy link
Author

cperk commented Sep 15, 2021

Hi! I totally understand that you couldn't resolve this issue right away; are you any closer?

@cperk
Copy link
Author

cperk commented Jul 10, 2022

any update?

@melwarden77
Copy link

I am having the same issue.

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

No branches or pull requests

3 participants