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

Use of table in xbgcnbd.PlotFrequencyInCalibration (and mcmc.PlotFrequencyInCalibration) #72

Open
SebDub opened this issue Jan 17, 2019 · 0 comments

Comments

@SebDub
Copy link

SebDub commented Jan 17, 2019

Hi!

First, thanks a lot for the package. Really useful stuff here.

I noticed what I think is a bug in xbgcnbd.PlotFrequencyInCalibration (and potentially in mcmc.PlotFrequencyInCalibration, but I didn't use it directly).
The behavior at the line
x_act <- table(x_act)
is not correct, to me, when a member of the series 0:censor is missing in the table, e.g. if our censor is at 52 and nobody made 20,35, or 45 repeat transactions.
It will not fill with 0 this frequency values and hence x_act will be smaller than x_ect and due to the way R handle this, the matrix will be ... strange (got a warning in Rstudio, didn't in Visual Studio)
It can be fixed by using:
x_act <- table(factor(x_act, levels=c(0:censor)))

See this toy example to understand what i mean:

censor=25

x_act <- c(1:10, 20:30)
x_act[x_act > censor] <- censor
x_act <- table(x_act)
x_est <- 0:censor
mat <- matrix(c(x_act, x_est), nrow = 2, ncol = censor + 1, byrow = TRUE)
mat

x_act2 <- c(1:10, 20:30)
x_act2[x_act2 > censor] <- censor
x_act2 <- table(factor(x_act2,levels=c(0:censor)))
x_est <- 0:censor
mat2 <- matrix(c(x_act2, x_est), nrow = 2, ncol = censor + 1, byrow = TRUE)
mat2

I know this is a limit case. But I encountered it analysing some 'small' data subset and thought it would be worth rising it up here.
I'd gladly submit a pull request if you want.

Cheers,
Sébastien

Ps: first post actually on github... please don't hate me if I'm too long...

@SebDub SebDub changed the title Use of table in xbgcnbd.PlotFrequencyInCalibration (and mcmc.PlotFrequencyInCalibratio) Use of table in xbgcnbd.PlotFrequencyInCalibration (and mcmc.PlotFrequencyInCalibration) Jan 17, 2019
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

1 participant