Skip to content

Commit

Permalink
Release v0.7.0
Browse files Browse the repository at this point in the history
* Spending models
* Rcpp expectation
* Fix pnbd LL
* Fix invalid covariate names

Co-authored-by: Patrik Schilter <[email protected]>
Co-authored-by: Niels Kübler <[email protected]>
Co-authored-by: Patrick Bachmann <[email protected]>
  • Loading branch information
3 people authored Oct 7, 2020
2 parents 2ffe72f + 57628d2 commit 590c074
Show file tree
Hide file tree
Showing 212 changed files with 6,815 additions and 3,051 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
^Walkthrough\.rmd$
^bibliography\.bib$
^man-roxygen$
^thoughts_parameterhandling\.rtf$
^vignettes/internal_docu/internal_docu.Rmd$
^\.github$
^cran-comments\.md$
^_pkgdown\.yml$
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ src/*.gcno
src/*.o.tmp
inst/doc
.DS_Store
check
33 changes: 22 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: CLVTools
Title: Tools for Customer Lifetime Value Estimation
Version: 0.6.0
Date: 2020-06-22
Version: 0.7.0
Date: 2020-08-26
Authors@R: c(
person(given="Patrick", family="Bachmann", email = "[email protected]", role = c("cre","aut")),
person(given="Jeffrey", family="Naef", email = "[email protected]",role = "aut"),
Expand Down Expand Up @@ -31,7 +31,6 @@ Imports:
stats,
utils
Suggests:
BTYD,
covr,
doFuture,
doParallel,
Expand All @@ -55,18 +54,24 @@ Collate:
'class_clv_data.R'
'class_clv_model.R'
'class_clv_fitted.R'
'class_clv_fitted_transactions.R'
'class_clv_model_nocorrelation.R'
'class_clv_model_bgnbd.R'
'class_clv_bgnbd.R'
'class_clv_fitted_staticcov.R'
'class_clv_fitted_transactions_staticcov.R'
'class_clv_data_staticcovariates.R'
'class_clv_model_bgnbd_staticcov.R'
'class_clv_bgnbd_staticcov.R'
'class_clv_data_dynamiccovariates.R'
'class_clv_fitted_dynamiccov.R'
'class_clv_fitted_spending.R'
'class_clv_fitted_transactions_dynamiccov.R'
'class_clv_model_gg.R'
'class_clv_gg.R'
'class_clv_model_ggomnbd_nocov.R'
'class_clv_ggomnbd.R'
'class_clv_model_ggomnbd_staticcov.R'
'class_clv_ggomnbd_staticcov.R'
'class_clv_model_withcorrelation.R'
'class_clv_model_pnbd.R'
'class_clv_model_pnbd_staticcov.R'
'class_clv_model_pnbd_dynamiccov.R'
Expand All @@ -88,24 +93,30 @@ Collate:
'f_generics_clvdata.R'
'f_generics_clvfitted.R'
'f_generics_clvfitted_estimate.R'
'f_generics_clvfitteddyncov.R'
'f_generics_clvfittedstaticcov.R'
'f_generics_clvfittedstaticcov_estimate.R'
'f_generics_clvfittedspending.R'
'f_generics_clvfittedtransactions.R'
'f_generics_clvfittedtransactionsdyncov.R'
'f_generics_clvfittedtransactionsstaticcov.R'
'f_generics_clvfittedtransactionsstaticcov_estimate.R'
'f_generics_clvpnbddyncov.R'
'f_interface_bgbb.R'
'f_interface_bgnbd.R'
'f_interface_clvdata.R'
'f_interface_gg.R'
'f_interface_ggomnbd.R'
'f_interface_pnbd.R'
'f_interface_predict_clvfittedspending.R'
'f_interface_predict_clvfittedtransactions.R'
'f_interface_setdynamiccovariates.R'
'f_interface_setstaticcovariates.R'
'f_s3generics_clvdata.R'
'f_s3generics_clvdata_dynamiccov.R'
'f_s3generics_clvdata_plot.R'
'f_s3generics_clvdata_staticcov.R'
'f_s3generics_clvfitted.R'
'f_s3generics_clvfitted_plot.R'
'f_s3generics_clvfitted_staticcov.R'
'f_s3generics_clvfittedspending_plot.R'
'f_s3generics_clvfittedtransactions_plot.R'
'f_s3generics_clvfittedtransactions_staticcov.R'
'f_s3generics_clvtime.R'
'interlayer_callLL.R'
'interlayer_callnextinterlayer.R'
Expand All @@ -124,5 +135,5 @@ Collate:
'pnbd_dyncov_expectation.R'
'pnbd_dyncov_makewalks.R'
'pnbd_dyncov_palive.R'
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
VignetteBuilder: knitr
15 changes: 10 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# Generated by roxygen2: do not edit by hand

S3method(coef,clv.fitted)
S3method(coef,clv.fitted.static.cov)
S3method(coef,clv.fitted.transactions.static.cov)
S3method(coef,summary.clv.fitted)
S3method(confint,clv.fitted)
S3method(fitted,clv.fitted)
S3method(logLik,clv.fitted)
S3method(nobs,clv.data)
S3method(nobs,clv.fitted)
S3method(plot,clv.data)
S3method(plot,clv.fitted)
S3method(predict,clv.fitted)
S3method(plot,clv.fitted.spending)
S3method(plot,clv.fitted.transactions)
S3method(predict,clv.fitted.spending)
S3method(predict,clv.fitted.transactions)
S3method(print,clv.data)
S3method(print,clv.data.dynamic.covariates)
S3method(print,clv.data.static.covariates)
S3method(print,clv.fitted)
S3method(print,clv.fitted.static.cov)
S3method(print,clv.fitted.transactions.static.cov)
S3method(print,clv.time)
S3method(print,summary.clv.data)
S3method(print,summary.clv.data.dynamic.covariates)
Expand All @@ -26,7 +28,7 @@ S3method(summary,clv.data)
S3method(summary,clv.data.dynamic.covariates)
S3method(summary,clv.data.static.covariates)
S3method(summary,clv.fitted)
S3method(summary,clv.fitted.static.cov)
S3method(summary,clv.fitted.transactions.static.cov)
S3method(summary,clv.time)
S3method(vcov,clv.fitted)
S3method(vcov,summary.clv.fitted)
Expand All @@ -35,6 +37,7 @@ export(SetStaticCovariates)
export(clvdata)
exportMethods(bgbb)
exportMethods(bgnbd)
exportMethods(gg)
exportMethods(ggomnbd)
exportMethods(plot)
exportMethods(pnbd)
Expand All @@ -57,7 +60,9 @@ importFrom(ggplot2,ggplot)
importFrom(ggplot2,guide_legend)
importFrom(ggplot2,labs)
importFrom(ggplot2,rel)
importFrom(ggplot2,scale_colour_manual)
importFrom(ggplot2,scale_fill_manual)
importFrom(ggplot2,stat_density)
importFrom(ggplot2,theme)
importFrom(graphics,plot)
importFrom(lubridate,ceiling_date)
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# CLVTools 0.7.0

### NEW FEATURES
* Refactor the Gamma-Gamma (GG) model to predict mean spending per transaction into an independent model
* The prediction for transaction models can now be combined with separately fit spending models
* Write the unconditional expectation functions in Rcpp for faster plotting (Pareto/NBD and Beta-Geometric/NBD)
* Improved documentation and walkthrough

### BUG FIXES
* Pareto/NBD LogLikelihood: For the case Tcal = t.x and for the case alpha == beta
* Static or dynamic covariates with syntactically invalid names (spaces, start with numbers, etc) could not be fit


# CLVTools 0.6.0

### NEW FEATURES
Expand Down
101 changes: 90 additions & 11 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ bgnbd_staticcov_LL_sum <- function(vParams, vX, vT_x, vT_cal, mCov_life, mCov_tr
.Call(`_CLVTools_bgnbd_staticcov_LL_sum`, vParams, vX, vT_x, vT_cal, mCov_life, mCov_trans)
}

bgnbd_staticcov_alpha_i <- function(alpha_0, vCovParams_trans, mCov_trans) {
.Call(`_CLVTools_bgnbd_staticcov_alpha_i`, alpha_0, vCovParams_trans, mCov_trans)
}

bgnbd_staticcov_a_i <- function(a_0, vCovParams_life, mCov_life) {
.Call(`_CLVTools_bgnbd_staticcov_a_i`, a_0, vCovParams_life, mCov_life)
}

bgnbd_staticcov_b_i <- function(b_0, vCovParams_life, mCov_life) {
.Call(`_CLVTools_bgnbd_staticcov_b_i`, b_0, vCovParams_life, mCov_life)
}

#' @name bgnbd_PAlive
#'
#' @templateVar name_model_full BG/NBD
Expand Down Expand Up @@ -98,6 +110,33 @@ bgnbd_staticcov_PAlive <- function(r, alpha, a, b, vX, vT_x, vT_cal, vCovParams_
.Call(`_CLVTools_bgnbd_staticcov_PAlive`, r, alpha, a, b, vX, vT_x, vT_cal, vCovParams_trans, vCovParams_life, mCov_trans, mCov_life)
}

#' @name bgnbd_expectation
#' @title BG/NBD: Unconditional Expectation
#'
#' @template template_expectation_description
#'
#' @template template_params_bgnbd
#' @template template_expectation_params
#' @param vAlpha_i Vector of individual parameters alpha
#' @param vA_i Vector of individual parameters a
#' @param vB_i Vector of individual parameters b
#'
#' @template template_references_bgnbd
#'
#' @template template_expectation_return
#'
NULL

#' @rdname bgnbd_expectation
bgnbd_nocov_expectation <- function(r, alpha, a, b, vT_i) {
.Call(`_CLVTools_bgnbd_nocov_expectation`, r, alpha, a, b, vT_i)
}

#' @rdname bgnbd_expectation
bgnbd_staticcov_expectation <- function(r, vAlpha_i, vA_i, vB_i, vT_i) {
.Call(`_CLVTools_bgnbd_staticcov_expectation`, r, vAlpha_i, vA_i, vB_i, vT_i)
}

#' @title GSL Hypergeom 2f0 for equal length vectors
#'
#' @param vA Vector of values for parameter a
Expand Down Expand Up @@ -218,6 +257,14 @@ ggomnbd_staticcov_LL_sum <- function(vParams, vX, vT_x, vT_cal, mCov_life, mCov_
.Call(`_CLVTools_ggomnbd_staticcov_LL_sum`, vParams, vX, vT_x, vT_cal, mCov_life, mCov_trans)
}

ggomnbd_staticcov_alpha_i <- function(alpha_0, vCovParams_trans, mCov_trans) {
.Call(`_CLVTools_ggomnbd_staticcov_alpha_i`, alpha_0, vCovParams_trans, mCov_trans)
}

ggomnbd_staticcov_beta_i <- function(beta_0, vCovParams_life, mCov_life) {
.Call(`_CLVTools_ggomnbd_staticcov_beta_i`, beta_0, vCovParams_life, mCov_life)
}

#' @name ggomnbd_PAlive
#'
#' @templateVar name_model_full GGompertz/NBD
Expand Down Expand Up @@ -250,20 +297,17 @@ ggomnbd_nocov_PAlive <- function(r, alpha_0, b, s, beta_0, vX, vT_x, vT_cal) {
#' @name ggomnbd_expectation
#' @title GGompertz/NBD: Unconditional Expectation
#'
#' @description Computes the expected number of repeat transactions in the interval (0, vT_i]
#' for a randomly selected customer, where 0 is defined as the point when the customer came alive.
#' @template template_expectation_description
#'
#' @template template_params_ggomnbd
#' @param vT_i Number of periods since the customer came alive
#' @template template_params_rcppcovmatrix
#' @template template_params_rcppvcovparams
#'
#' @templateVar name_params_cov_life vCovParams_life
#' @templateVar name_params_cov_trans vCovParams_trans
#' @template template_details_rcppcovmatrix
#' @template template_expectation_params
#' @param vAlpha_i Vector of individual parameters alpha
#' @param vBeta_i Vector of individual parameters beta
#'
#' @template template_references_ggomnbd
#'
#' @template template_expectation_return
#'
NULL

#' @rdname ggomnbd_expectation
Expand All @@ -272,8 +316,8 @@ ggomnbd_nocov_expectation <- function(r, alpha_0, b, s, beta_0, vT_i) {
}

#' @rdname ggomnbd_expectation
ggomnbd_staticcov_expectation <- function(r, alpha_0, b, s, beta_0, vT_i, vCovParams_trans, vCovParams_life, mCov_life, mCov_trans) {
.Call(`_CLVTools_ggomnbd_staticcov_expectation`, r, alpha_0, b, s, beta_0, vT_i, vCovParams_trans, vCovParams_life, mCov_life, mCov_trans)
ggomnbd_staticcov_expectation <- function(r, b, s, vAlpha_i, vBeta_i, vT_i) {
.Call(`_CLVTools_ggomnbd_staticcov_expectation`, r, b, s, vAlpha_i, vBeta_i, vT_i)
}

#' @name pnbd_CET
Expand Down Expand Up @@ -385,6 +429,14 @@ pnbd_staticcov_LL_sum <- function(vParams, vX, vT_x, vT_cal, mCov_life, mCov_tra
.Call(`_CLVTools_pnbd_staticcov_LL_sum`, vParams, vX, vT_x, vT_cal, mCov_life, mCov_trans)
}

pnbd_staticcov_alpha_i <- function(alpha_0, vCovParams_trans, mCov_trans) {
.Call(`_CLVTools_pnbd_staticcov_alpha_i`, alpha_0, vCovParams_trans, mCov_trans)
}

pnbd_staticcov_beta_i <- function(beta_0, vCovParams_life, mCov_life) {
.Call(`_CLVTools_pnbd_staticcov_beta_i`, beta_0, vCovParams_life, mCov_life)
}

#' @name pnbd_PAlive
#'
#' @templateVar name_model_full Pareto/NBD
Expand Down Expand Up @@ -414,3 +466,30 @@ pnbd_staticcov_PAlive <- function(r, alpha_0, s, beta_0, vX, vT_x, vT_cal, vCovP
.Call(`_CLVTools_pnbd_staticcov_PAlive`, r, alpha_0, s, beta_0, vX, vT_x, vT_cal, vCovParams_trans, vCovParams_life, mCov_trans, mCov_life)
}

#' @name pnbd_expectation
#' @title Pareto/NBD: Unconditional Expectation
#'
#' @template template_expectation_description
#'
#' @template template_params_pnbd
#' @template template_expectation_params
#' @param vAlpha_i Vector of individual parameters alpha
#' @param vBeta_i Vector of individual parameters beta
#'
#'
#' @template template_references_pnbd
#'
#' @template template_expectation_return
#'
NULL

#' @rdname pnbd_expectation
pnbd_nocov_expectation <- function(r, s, alpha_0, beta_0, vT_i) {
.Call(`_CLVTools_pnbd_nocov_expectation`, r, s, alpha_0, beta_0, vT_i)
}

#' @rdname pnbd_expectation
pnbd_staticcov_expectation <- function(r, s, vAlpha_i, vBeta_i, vT_i) {
.Call(`_CLVTools_pnbd_staticcov_expectation`, r, s, vAlpha_i, vBeta_i, vT_i)
}

Loading

0 comments on commit 590c074

Please sign in to comment.