BTYD (Buy 'Till You Die). Walkthrough. pnbd.EstimateParameters()

…衆ロ難τιáo~ 提交于 2020-01-03 01:56:08

问题


This is the first time I am working on BTYD procedure. I am having errors running the parameter estimates. I have provided the error message below. I have been following the BTYD - Walkthrough.

Does anybody know how to fix this? I worked through the sample data set and it works fine. I uploaded my file in the same format, it wouldn't work. There are no missing or empty rows/values. Help would be greatly appreciated!!!

end.of.cal.period <- as.Date("2013-08-18")
elog.cal <- elog[which(elog$date <= end.of.cal.period), ]

split.data <- dc.SplitUpElogForRepeatTrans(elog.cal);
clean.elog <- split.data$repeat.trans.elog; 
#clean.elog
freq.cbt <- dc.CreateFreqCBT(clean.elog); 
freq.cbt[1:3,1:5]

tot.cbt <- dc.CreateFreqCBT(elog.cal) #used elog.cal instead of elog
cal.cbt <- dc.MergeCustomers(tot.cbt, freq.cbt)

birth.periods <- split.data$cust.data$birth.per
last.dates <- split.data$cust.data$last.date
cal.cbs.dates <- data.frame(birth.periods, last.dates, end.of.cal.period)
cal.cbs <- dc.BuildCBSFromCBTAndDates(cal.cbt, cal.cbs.dates,per="week") #works. no errors
head(cal.cbs, n=10)

sel <- cbind(cal.cbs)
colnames(sel) <-c('x', 't.x', 'T.cal')
head(sel, n=10)

params <- pnbd.EstimateParameters(sel)

Error in optim(logparams, pnbd.eLL, cal.cbs = cal.cbs, max.param.value = max.param.value, : L-BFGS-B needs finite values of 'fn'


回答1:


It turns out that when estimating the parameters, large values in sel$x will cause the exponentiation to blow up and error.

This guy has a fix on github here: https://github.com/theofilos/BTYD

I basically took all of his code in pnbd.R, and prepend it to my code for the Pareto/NBD analysis and it seems to fix that issue.




回答2:


Have you tried adjusting the starting parameters? They default to 1,1,1,1. Something like:

startingparams <- c(.1, 3, .1, .1)
params <- pnbd.EstimateParameters(sel, startingparams)

Play with different orders of magnitude and see if any stick. Alternatively, check your maximum 'x' value in the cbs matrix. If there are extreme outliers you may want to remove them and try estimating the parameters again.



来源:https://stackoverflow.com/questions/26429008/btyd-buy-till-you-die-walkthrough-pnbd-estimateparameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!