Skip to content

Commit

Permalink
added missing (M)BG/CNBD-k plot methods
Browse files Browse the repository at this point in the history
fixes #35 
- added `(m)bgcnbd.PlotFreqVsConditionalExpectedFrequency` methods
- added `(m)bgcnbd.PlotRecVsConditionalExpectedFrequency` methods
  • Loading branch information
mplatzer authored Jan 25, 2017
1 parent 5297938 commit 63e95cf
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ linters: with_defaults(
multiple_dots_linter = NULL,
camel_case_linter = NULL,
spaces_left_parentheses_linter = NULL)
exclusions: list("R/RcppExports.R", "doc/*")
exclusions: list("R/RcppExports.R", "inst/doc/BTYDplus-HowTo.R", "tests/testthat/*")
exclude: "# nolint"
exclude_start: "# nolint start"
exclude_end: "# nolint end"
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: BTYDplus
Type: Package
Title: Probabilistic Models for Assessing and Predicting your Customer Base
Version: 1.0.2
Version: 1.1.0
Authors@R: person("Michael", "Platzer", email = "[email protected]", role = c("aut", "cre"))
Description: Provides advanced statistical methods to describe and predict customers'
purchase behavior in a non-contractual setting. It uses historic transaction records to fit a
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export(bgcnbd.ExpectedCumulativeTransactions)
export(bgcnbd.GenerateData)
export(bgcnbd.LL)
export(bgcnbd.PAlive)
export(bgcnbd.PlotFreqVsConditionalExpectedFrequency)
export(bgcnbd.PlotFrequencyInCalibration)
export(bgcnbd.PlotRecVsConditionalExpectedFrequency)
export(bgcnbd.PlotTrackingCum)
export(bgcnbd.PlotTrackingInc)
export(bgcnbd.cbs.LL)
Expand All @@ -25,7 +27,9 @@ export(mbgcnbd.ExpectedCumulativeTransactions)
export(mbgcnbd.GenerateData)
export(mbgcnbd.LL)
export(mbgcnbd.PAlive)
export(mbgcnbd.PlotFreqVsConditionalExpectedFrequency)
export(mbgcnbd.PlotFrequencyInCalibration)
export(mbgcnbd.PlotRecVsConditionalExpectedFrequency)
export(mbgcnbd.PlotTrackingCum)
export(mbgcnbd.PlotTrackingInc)
export(mbgcnbd.cbs.LL)
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.1.0
- added `(m)bgcnbd.PlotFreqVsConditionalExpectedFrequency` methods
- added `(m)bgcnbd.PlotRecVsConditionalExpectedFrequency` methods

1.0.2
- speed up `xbgcnbd.EstimateParameters` by lowering lower bound of early stop to k=3

Expand Down
80 changes: 80 additions & 0 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,83 @@ dc.PlotTracking <- function(actual, expected, T.cal = NULL,
legend(pos, legend = c("Actual", "Model"), col = 1:2, lty = 1:2, lwd = 1)
return(rbind(actual, expected))
}


#' Generic Method for Plotting Frequency vs. Conditional Expected Frequency
#'
#' @keywords internal
dc.PlotFreqVsConditionalExpectedFrequency <- function(x, actual, expected, censor,
xlab, ylab, xticklab, title) {

bin <- NULL # suppress checkUsage warnings
if (length(x) != length(actual) | length(x) != length(expected) |
!is.numeric(x) | !is.numeric(actual) | !is.numeric(expected) |
any(x < 0) | any(actual < 0) | any(expected < 0))
stop("x, actual and expected must be non-negative numeric vectors of same length.")

if (censor > max(x)) censor <- max(x)
dt <- data.table(x, actual, expected)
dt[, bin := pmin(x, censor)]
st <- dt[, .(transaction.actual = mean(actual),
transaction.expected = mean(expected),
bin.size = .N), keyby = bin]
st <- merge(data.table(bin = 0:censor), st, all.x = TRUE, by = "bin")
comparison <- t(st)[-1, ]
col.names <- paste(rep("freq", length(censor + 1)), (0:censor), sep = ".")
col.names[censor + 1] <- paste0(col.names[censor + 1], "+")
colnames(comparison) <- col.names
if (is.null(xticklab) == FALSE) {
x.labels <- xticklab
} else {
if (censor < ncol(comparison)) {
x.labels <- 0:(censor)
x.labels[censor + 1] <- paste0(censor, "+")
} else {
x.labels <- 0:(ncol(comparison))
}
}
actual <- comparison[1, ]
expected <- comparison[2, ]
ylim <- c(0, ceiling(max(c(actual, expected)) * 1.1))
plot(actual, type = "l", xaxt = "n", col = 1, ylim = ylim, xlab = xlab, ylab = ylab, main = title)
lines(expected, lty = 2, col = 2)
axis(1, at = 1:ncol(comparison), labels = x.labels)
legend("topleft", legend = c("Actual", "Model"), col = 1:2, lty = 1:2, lwd = 1)
return(comparison)
}


#' Generic Method for Plotting Frequency vs. Conditional Expected Frequency
#'
#' @keywords internal
dc.PlotRecVsConditionalExpectedFrequency <- function(t.x, actual, expected,
xlab, ylab, xticklab, title) {

bin <- NULL # suppress checkUsage warnings
if (length(t.x) != length(actual) | length(t.x) != length(expected) |
!is.numeric(t.x) | !is.numeric(actual) | !is.numeric(expected) |
any(t.x < 0) | any(actual < 0) | any(expected < 0))
stop("t.x, actual and expected must be non-negative numeric vectors of same length.")

dt <- data.table(t.x, actual, expected)
dt[, bin := floor(t.x)]
st <- dt[, .(actual = mean(actual),
expected = mean(expected),
bin.size = .N), keyby = bin]
st <- merge(data.table(bin = 1:floor(max(t.x))), st[bin > 0], all.x = TRUE, by = "bin")
comparison <- t(st)[-1, ]
x.labels <- NULL
if (is.null(xticklab) == FALSE) {
x.labels <- xticklab
} else {
x.labels <- 1:max(st$bin)
}
actual <- comparison[1, ]
expected <- comparison[2, ]
ylim <- c(0, ceiling(max(c(actual, expected), na.rm = TRUE) * 1.1))
plot(actual, type = "l", xaxt = "n", col = 1, ylim = ylim, xlab = xlab, ylab = ylab, main = title)
lines(expected, lty = 2, col = 2)
axis(1, at = 1:ncol(comparison), labels = x.labels)
legend("topleft", legend = c("Actual", "Model"), col = 1:2, lty = 1:2, lwd = 1)
return(comparison)
}
107 changes: 106 additions & 1 deletion R/mbg-cnbd-k.R
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ xbgcnbd.ConditionalExpectedTransactions <- function(params, T.star, x, t.x, T.ca
#'
#' @param params A vector with model parameters \code{k}, \code{r},
#' \code{alpha}, \code{a} and \code{b}, in that order.
#' @param cal.cbs calibration period CBS (customer by sufficient statistic). It
#' @param cal.cbs Calibration period CBS (customer by sufficient statistic). It
#' must contain columns for frequency ('x') and total time observed ('T.cal').
#' @param censor Cutoff point for number of transactions in plot.
#' @param xlab Descriptive label for the x axis.
Expand Down Expand Up @@ -823,6 +823,111 @@ xbgcnbd.PlotTrackingInc <- function(params, T.cal, T.tot, actual.inc.tracking.da



#' (M)BG/CNBD-k Plot Frequency vs. Conditional Expected Frequency
#'
#' Plots the actual and conditional expected number transactions made by
#' customers in the holdout period, binned according to calibration period
#' frequencies, and returns this comparison in a matrix.
#'
#' @param params A vector with model parameters \code{k}, \code{r},
#' \code{alpha}, \code{a} and \code{b}, in that order.
#' @param T.star Length of the holdout period.
#' @param cal.cbs Calibration period CBS (customer by sufficient statistic). It
#' must contain columns for frequency ('x'), recency ('t.x') and total time
#' observed ('T.cal').
#' @param x.star Vector of transactions made by each customer in the holdout period.
#' @param censor Cutoff point for number of transactions in plot.
#' @param xlab Descriptive label for the x axis.
#' @param ylab Descriptive label for the x axis.
#' @param xticklab A vector containing a label for each tick mark on the x axis.
#' @param title Title placed on the top-center of the plot.
#' @return Holdout period transaction frequency comparison matrix (actual vs. expected).
#' @export
#' @seealso \code{\link{bgcnbd.PlotFreqVsConditionalExpectedFrequency}}
#' @examples
#' \dontrun{
#' data("groceryElog")
#' cbs <- elog2cbs(groceryElog, T.cal = "2006-09-30")
#' params <- mbgcnbd.EstimateParameters(cbs, k=2)
#' mbgcnbd.PlotFreqVsConditionalExpectedFrequency(params, T.star=52, cbs, cbs$x.star, censor=7)
#' }
mbgcnbd.PlotFreqVsConditionalExpectedFrequency <- function(params, T.star, cal.cbs, x.star,
censor, xlab = "Calibration period transactions",
ylab = "Holdout period transactions", xticklab = NULL,
title = "Conditional Expectation") {
x.star.est <- mbgcnbd.ConditionalExpectedTransactions(params, T.star, cal.cbs$x, cal.cbs$t.x, cal.cbs$T.cal)
dc.PlotFreqVsConditionalExpectedFrequency(x = cal.cbs$x, actual = x.star, expected = x.star.est,
censor = censor, xlab = xlab, ylab = ylab, xticklab = xticklab,
title = title)
}

#' @rdname mbgcnbd.PlotFreqVsConditionalExpectedFrequency
#' @export
bgcnbd.PlotFreqVsConditionalExpectedFrequency <- function(params, T.star, cal.cbs, x.star,
censor, xlab = "Calibration period transactions",
ylab = "Holdout period transactions", xticklab = NULL,
title = "Conditional Expectation") {
x.star.est <- bgcnbd.ConditionalExpectedTransactions(params, T.star, cal.cbs$x, cal.cbs$t.x, cal.cbs$T.cal)
dc.PlotFreqVsConditionalExpectedFrequency(x = cal.cbs$x, actual = x.star, expected = x.star.est,
censor = censor, xlab = xlab, ylab = ylab, xticklab = xticklab,
title = title)
}



#' (M)BG/CNBD-k Plot Actual vs. Conditional Expected Frequency by Recency
#'
#' Plots the actual and conditional expected number transactions made by
#' customers in the holdout period, binned according to calibration period
#' recencies, and returns this comparison in a matrix.
#'
#' @param params A vector with model parameters \code{k}, \code{r},
#' \code{alpha}, \code{a} and \code{b}, in that order.
#' @param cal.cbs Calibration period CBS (customer by sufficient statistic). It
#' must contain columns for frequency ('x'), recency ('t.x') and total time
#' observed ('T.cal').
#' @param T.star Length of the holdout period.
#' @param x.star Vector of transactions made by each customer in the holdout period.
#' @param xlab Descriptive label for the x axis.
#' @param ylab Descriptive label for the x axis.
#' @param xticklab A vector containing a label for each tick mark on the x axis.
#' @param title Title placed on the top-center of the plot.
#' @return Matrix comparing actual and conditional expected transactions in the holdout period.
#' @export
#' @seealso \code{\link{bgcnbd.PlotFreqVsConditionalExpectedFrequency}}
#' @examples
#' \dontrun{
#' data("groceryElog")
#' cbs <- elog2cbs(groceryElog, T.cal = "2006-09-30")
#' params <- mbgcnbd.EstimateParameters(cbs, k=2)
#' mbgcnbd.PlotRecVsConditionalExpectedFrequency(params, cbs, T.star=52, cbs$x.star)
#' }
mbgcnbd.PlotRecVsConditionalExpectedFrequency <- function(
params, cal.cbs, T.star, x.star,
xlab = "Calibration period recency",
ylab = "Holdout period transactions", xticklab = NULL,
title = "Actual vs. Conditional Expected Transactions by Recency") {
x.star.est <- mbgcnbd.ConditionalExpectedTransactions(params, T.star, cal.cbs$x, cal.cbs$t.x, cal.cbs$T.cal)
dc.PlotRecVsConditionalExpectedFrequency(t.x = cal.cbs$t.x, actual = x.star, expected = x.star.est,
xlab = xlab, ylab = ylab, xticklab = xticklab,
title = title)
}

#' @rdname mbgcnbd.PlotRecVsConditionalExpectedFrequency
#' @export
bgcnbd.PlotRecVsConditionalExpectedFrequency <- function(
params, cal.cbs, T.star, x.star,
xlab = "Calibration period recency",
ylab = "Holdout period transactions", xticklab = NULL,
title = "Actual vs. Conditional Expected Transactions by Recency") {
x.star.est <- bgcnbd.ConditionalExpectedTransactions(params, T.star, cal.cbs$x, cal.cbs$t.x, cal.cbs$T.cal)
dc.PlotRecVsConditionalExpectedFrequency(t.x = cal.cbs$t.x, actual = x.star, expected = x.star.est,
xlab = xlab, ylab = ylab, xticklab = xticklab,
title = title)
}



#' Simulate data according to (M)BG/CNBD-k model assumptions
#'
#' @param n Number of customers.
Expand Down
14 changes: 14 additions & 0 deletions man/dc.PlotFreqVsConditionalExpectedFrequency.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/dc.PlotRecVsConditionalExpectedFrequency.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions man/mbgcnbd.PlotFreqVsConditionalExpectedFrequency.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mbgcnbd.PlotFrequencyInCalibration.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

2 comments on commit 63e95cf

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/testthat/test-bg-cnbd-k.R:31:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.ConditionalExpectedTransactions(params[-1], 32, 1, 16, 32),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:36:1: style: lines should not be more than 80 characters.

​               bgcnbd.PlotFrequencyInCalibration(params, cbs, 7), tolerance = 0.01)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:37:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.PlotFreqVsConditionalExpectedFrequency(params[-1], T.star = 39, cbs, cbs$x.star, 7),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:38:1: style: lines should not be more than 80 characters.

​               bgcnbd.PlotFreqVsConditionalExpectedFrequency(params, T.star = 39, cbs, cbs$x.star, 7), tolerance = 0.01)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:39:1: style: lines should not be more than 80 characters.

# Note: BTYD::bgnbd.PlotRecVsConditionalExpectedFrequency can't handle missing bins, so we can't compare
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:40:1: style: lines should not be more than 80 characters.

​  expect_silent(bgcnbd.PlotRecVsConditionalExpectedFrequency(params, cbs, T.star = 39, cbs$x.star))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:42:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.PlotTrackingInc(params[-1], cbs$T.cal, max(cbs$T.cal) + 32, inc_tracking),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:43:1: style: lines should not be more than 80 characters.

​               bgcnbd.PlotTrackingInc(params, cbs$T.cal, max(cbs$T.cal) + 32, inc_tracking),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:45:1: style: lines should not be more than 80 characters.

​  expect_silent(bgcnbd.PlotTrackingInc(params, cbs$T.cal, max(cbs$T.cal) + 32, inc_tracking,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:47:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.ExpectedCumulativeTransactions(params[-1], 11, 39, 12),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:51:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.PlotTrackingCum(params[-1], cbs$T.cal, 32 + 32, cu_tracking),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:69:1: style: lines should not be more than 80 characters.

est_fixed_k <- bgcnbd.EstimateParameters(cbs[, c("x", "t.x", "T.cal", "litt")], k = params[1])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:76:1: style: lines should not be more than 80 characters.

cbs$x.est32 <- bgcnbd.ConditionalExpectedTransactions(params, 32, cbs$x, cbs$t.x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:77:1: style: lines should not be more than 80 characters.

cbs$x.est64 <- bgcnbd.ConditionalExpectedTransactions(params, 64, cbs$x, cbs$t.x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:5:1: style: lines should not be more than 80 characters.

elog <- data.frame(cust = c(1, 1, 1, 1, 1, 2, 3), date = Sys.Date() + c(0, 14, 14, 28, 35, 7, 24))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:6:1: style: lines should not be more than 80 characters.

elog_time <- data.frame(cust = c(1, 1, 1, 1, 1, 2, 3), date = Sys.time() + c(0, 14, 14, 28, 35, 7, 24))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:7:14: style: Words within variable and function names should be separated by '_' rather than '.'.

elog_dt <- as.data.table(elog)
             ^~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:19:1: style: lines should not be more than 80 characters.

​  expect_equal(elog2cbs(elog_time, units = "secs", T.cal = as.character(min(elog_time$date) + 21))[, 1:4],
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:20:1: style: lines should not be more than 80 characters.

​               elog2cbs(elog, units = "days", T.cal = as.character(Sys.Date() + 21))[, 1:4])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:30:1: style: lines should not be more than 80 characters.

​               c("cust", "x", "t.x", "litt", "sales", "first", "T.cal", "T.star", "x.star", "sales.star"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:32:1: style: lines should not be more than 80 characters.

​               c("cust", "x", "t.x", "litt", "first", "T.cal", "T.star", "x.star"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:34:1: style: lines should not be more than 80 characters.

​               c("cust", "x", "t.x", "litt", "first", "T.cal", "T.star", "x.star"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:37:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(elog$cust), nrow(elog2cbs(elog)))
               ^~~~~~~

tests/testthat/test-elog2cbs.R:38:1: style: lines should not be more than 80 characters.

​  expect_equal(uniqueN(elog[elog$date <= T.cal, "cust"]), nrow(elog2cbs(elog, T.cal = T.cal)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:38:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(elog[elog$date <= T.cal, "cust"]), nrow(elog2cbs(elog, T.cal = T.cal)))
               ^~~~~~~

tests/testthat/test-elog2cbs.R:42:1: style: lines should not be more than 80 characters.

​  expect_equal(uniqueN(elog_dt[, .(cust, date)]), sum(cbs$x) + sum(cbs$x.star) + nrow(cbs))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:42:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(elog_dt[, .(cust, date)]), sum(cbs$x) + sum(cbs$x.star) + nrow(cbs))
               ^~~~~~~

tests/testthat/test-elog2cbs.R:47:1: style: lines should not be more than 80 characters.

​  expect_equal(uniqueN(elog_dt[elog_dt$first <= T.cal & date <= T.tot, .(cust, date)]),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:47:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(elog_dt[elog_dt$first <= T.cal & date <= T.tot, .(cust, date)]),
               ^~~~~~~

tests/testthat/test-elog2cbs.R:52:1: style: lines should not be more than 80 characters.

​  expect_equal(elog_s[first <= T.cal & date <= T.cal, sum(sales)], sum(cbs$sales))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:53:1: style: lines should not be more than 80 characters.

​  expect_equal(elog_s[first <= T.cal & date <= T.tot, sum(sales)], sum(cbs$sales) + sum(cbs$sales.star))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:56:1: style: lines should not be more than 80 characters.

cbs <- elog2cbs(elog_s, T.cal = as.character(T.cal), T.tot = as.character(T.tot))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:64:1: style: lines should not be more than 80 characters.

​  expect_equal(elog2cbs(elog, units = "hours")$t.x / (7 * 24), elog2cbs(elog)$t.x)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:65:1: style: lines should not be more than 80 characters.

elog_time <- data.frame(cust = c(1, 1, 1, 1, 1, 2, 3), date = Sys.time() + c(0, 14, 14, 28, 35, 7, 24))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:66:1: style: lines should not be more than 80 characters.

​  expect_equal(elog2cbs(elog, units = "days")[, c(1:4, 6)], elog2cbs(elog_time, units = "secs")[, c(1:4, 6)])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:8:1: style: lines should not be more than 80 characters.

​  expect_silent(BTYDplus:::dc.check.model.params.safe(printnames, params, "foo"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:12:1: style: lines should not be more than 80 characters.

​  expect_silent(BTYDplus:::dc.check.model.params.safe(printnames, params, "foo"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:25:1: style: lines should not be more than 80 characters.

col.names = c("cust", "sampleid", "date", "cds", "sales"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:28:15: style: Variable and function names should be all lowercase.

utils::data(cdnowSummary, package = "BTYD", envir = environment())
              ^~~~~~~~~~~~

tests/testthat/test-helpers.R:29:21: style: Variable and function names should be all lowercase.

​  expect_equal(cum, cdnowSummary$cu.tracking)
                    ^~~~~~~~~~~~

tests/testthat/test-helpers.R:37:1: style: lines should not be more than 80 characters.

​  expect_equal(diff(elog2cum(elog, by = 7, first = TRUE)), elog2inc(elog, by = 7, first = TRUE))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:39:1: style: lines should not be more than 80 characters.

​  expect_equal(tail(elog2cum(elog, by = 1, first = FALSE), 1), nrow(elog) - uniqueN(elog$cust))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:39:77: style: Variable and function names should be all lowercase.

​  expect_equal(tail(elog2cum(elog, by = 1, first = FALSE), 1), nrow(elog) - uniqueN(elog$cust))
                                                                            ^~~~~~~

tests/testthat/test-helpers.R:41:1: style: lines should not be more than 80 characters.

elog <- data.table(cust = c(1, 1, 1, 1, 1, 3, 3), t = c(0, 9, 9, 20, 22, 4, 6))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:51:1: style: lines should not be more than 80 characters.

​  expect_silent(plotTimingPatterns(groceryElog, headers = c("X", "Y"), title = ""))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:52:1: style: lines should not be more than 80 characters.

​  expect_silent(plotTimingPatterns(groceryElog, T.cal = "2006-12-31", title = NULL))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:53:1: style: lines should not be more than 80 characters.

​  expect_silent(plotTimingPatterns(groceryElog, T.cal = "2006-12-31", T.tot = "2007-06-30",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:57:1: style: lines should not be more than 80 characters.

​  expect_silent(plotTimingPatterns(head(groceryElog, 10), T.cal = "2006-12-31", T.tot = "2007-12-30"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:20:1: style: lines should not be more than 80 characters.

est2 <- mbgcnbd.EstimateParameters(cbs[, c("x", "t.x", "T.cal", "litt")], k = 2)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:28:1: style: lines should not be more than 80 characters.

cbs$x.est <- mbgcnbd.ConditionalExpectedTransactions(params, cbs$T.star, cbs$x, cbs$t.x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:47:1: style: lines should not be more than 80 characters.

​  expect_silent(mbgcnbd.PlotTrackingInc(params, cbs$T.cal, max(cbs$T.cal + cbs$T.star), elog2inc(elog, by = 14)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:48:1: style: lines should not be more than 80 characters.

​  expect_silent(mbgcnbd.PlotTrackingCum(params, cbs$T.cal, max(cbs$T.cal + cbs$T.star), elog2cum(elog, by = 14)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:51:1: style: lines should not be more than 80 characters.

mat <- mbgcnbd.PlotFreqVsConditionalExpectedFrequency(params, cbs$T.star, cbs, cbs$x.star, 7)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:55:1: style: lines should not be more than 80 characters.

​  expect_lt(mbgcnbd.ConditionalExpectedTransactions(params, T.star = 32, x = c(0, 1), t.x = c(0, 12), T.cal = 32)[2], 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:56:1: style: lines should not be more than 80 characters.

​  expect_true(mbgcnbd.ConditionalExpectedTransactions(params, T.star = 32, x = 3, t.x = 12, T.cal = 32) !=
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:57:1: style: lines should not be more than 80 characters.

​                mbgcnbd.ConditionalExpectedTransactions(params, T.star = 32, x = 2, t.x = 12, T.cal = 32))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:67:1: style: lines should not be more than 80 characters.

cbs$x.est <- mbgcnbd.ConditionalExpectedTransactions(params, cbs$T.star, cbs$x, cbs$t.x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:17:1: style: lines should not be more than 80 characters.

abe_params$beta <- matrix(c(0.18, -2.5, 0.5, -0.3, -0.2, 0.8), byrow = TRUE, ncol = 2)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:20:1: style: lines should not be more than 80 characters.

abe_draws <- abe.mcmc.DrawParameters(abe_cbs, c("covariate_1", "covariate_2"), mcmc, burnin, thin, chains)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:25:1: style: lines should not be more than 80 characters.

pggg_draws <- pggg.mcmc.DrawParameters(pggg_cbs, mcmc / 10, burnin / 10, thin / 10, chains)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:32:1: style: lines should not be more than 80 characters.

pnbd_xstar_draws1 <- mcmc.DrawFutureTransactions(pnbd_cbs, pnbd_draws, sample_size = size)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:35:1: style: lines should not be more than 80 characters.

pnbd_xstar_draws2 <- mcmc.DrawFutureTransactions(pnbd_cbs, pnbd_draws, sample_size = size)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:37:1: style: lines should not be more than 80 characters.

​  expect_gt(cor(apply(pnbd_xstar_draws2, 2, mean), apply(pnbd_xstar_draws, 2, mean)), 0.95)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:38:1: style: lines should not be more than 80 characters.

​  expect_silent(pnbd_xstar_draws <- mcmc.DrawFutureTransactions(pnbd_cbs, pnbd_draws, T.star = 10))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:46:1: style: lines should not be more than 80 characters.

​  expect_equal(dim(pnbd_xstar_draws3), c((mcmc + burnin - burnin2) * chains / thin, nrow(pnbd_cbs)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:46:42: style: Place a space before left parenthesis, except in a function call.

​  expect_equal(dim(pnbd_xstar_draws3), c((mcmc + burnin - burnin2) * chains / thin, nrow(pnbd_cbs)))
                                         ^

tests/testthat/test-mcmc.R:85:1: style: lines should not be more than 80 characters.

​  expect_equal(mcmc.Expectation(pnbd_draws, 28), mean(pnbd_cbs$x), tolerance = 0.1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:86:1: style: lines should not be more than 80 characters.

x <- mcmc.ExpectedCumulativeTransactions(pnbd_draws, T.cal = pnbd_cbs$T.cal, T.tot = 56, n.periods.final = 56)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:99:1: style: lines should not be more than 80 characters.

BTYD::pnbd.PlotFrequencyInCalibration(unlist(pnbd_params), pnbd_cbs, censor = 7),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-nbd.R:18:1: style: lines should not be more than 80 characters.

cbs$x.est <- nbd.ConditionalExpectedTransactions(params, cbs$T.star, cbs$x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-ggg-mcmc.R:12:37: style: Words within variable and function names should be separated by '_' rather than '.'.

draws <- pggg.mcmc.DrawParameters(as.data.table(cbs),
                                    ^~~~~~~~~~~~~

tests/testthat/test-pareto-ggg-mcmc.R:13:1: style: lines should not be more than 80 characters.

mcmc = 10, burnin = 0, thin = 1, mc.cores = 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-ggg-mcmc.R:14:1: style: lines should not be more than 80 characters.

param_init = list(r = 1, alpha = 1, s = 1, beta = 1, t = 1, gamma = 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-ggg-mcmc.R:16:1: style: lines should not be more than 80 characters.

mcmc = 100, burnin = 20, thin = 10, chains = 2, mc.cores = 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:9:1: style: lines should not be more than 80 characters.

params$beta <- matrix(c(0.18, -2.5, 0.5, -0.3, -0.2, 0.8), byrow = TRUE, ncol = 2)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:11:1: style: lines should not be more than 80 characters.

​  expect_silent(abe.GenerateData(n = 100, T.cal = 32, T.star = c(16, 32), params))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:21:1: style: lines should not be more than 80 characters.

draws <- abe.mcmc.DrawParameters(as.data.table(cbs), covariates = c("covariate_1"),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:21:36: style: Words within variable and function names should be separated by '_' rather than '.'.

draws <- abe.mcmc.DrawParameters(as.data.table(cbs), covariates = c("covariate_1"),
                                   ^~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:22:1: style: lines should not be more than 80 characters.

mcmc = 10, burnin = 0, thin = 1, mc.cores = 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:25:1: style: lines should not be more than 80 characters.

draws <- abe.mcmc.DrawParameters(cbs, covariates = c("covariate_1", "covariate_2"), mc.cores = 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:28:1: style: lines should not be more than 80 characters.

​  expect_true(all(c("lambda", "mu", "z", "tau") %in% colnames(as.matrix(draws$level_1[[1]]))))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:29:1: style: lines should not be more than 80 characters.

​  expect_true(all(c("log_lambda_intercept", "log_mu_intercept", "log_lambda_covariate_1", "log_mu_covariate_1",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:30:1: style: lines should not be more than 80 characters.

"log_lambda_covariate_2", "log_mu_covariate_2", "var_log_lambda", "cov_log_lambda_log_mu", "var_log_mu") %in%
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:38:1: style: lines should not be more than 80 characters.

​  expect_equal(matrix(est[1:6], ncol = 2, byrow = T), params$beta, tolerance = 0.05)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:41:1: style: lines should not be more than 80 characters.

​  expect_equal(unname(est["var_log_lambda"]), params$gamma[1, 1], tolerance = 0.1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:42:1: style: lines should not be more than 80 characters.

​  expect_equal(unname(est["cov_log_lambda_log_mu"]), params$gamma[1, 2], tolerance = 0.1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:17:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(sim$elog$cust), n)
               ^~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:30:1: style: lines should not be more than 80 characters.

sim <- pggg.GenerateData(100, 52, c(26, 104), params, date.zero = as.Date("2010-01-01"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:61:37: style: Words within variable and function names should be separated by '_' rather than '.'.

draws <- pnbd.mcmc.DrawParameters(as.data.table(cbs),
                                    ^~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:62:1: style: lines should not be more than 80 characters.

mcmc = 10, burnin = 0, thin = 1, mc.cores = 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:63:1: style: lines should not be more than 80 characters.

param_init = list(r = 1, alpha = 1, s = 1, beta = 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:95:1: style: lines should not be more than 80 characters.

mcmc = 10, burnin = 0, thin = 2, chains = 2,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:96:1: style: lines should not be more than 80 characters.

use_data_augmentation = FALSE, mc.cores = 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-timing.R:17:1: style: lines should not be more than 80 characters.

​  expect_error(k_est_1 <- estimateRegularity(elog, plot = TRUE, min = 60), "sufficient")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-timing.R:21:1: style: lines should not be more than 80 characters.

k_est_3 <- estimateRegularity(elog, method = "mle-minka", plot = TRUE, title = "Plot Title")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-timing.R:22:1: style: lines should not be more than 80 characters.

k_est_4 <- estimateRegularity(elog, method = "mle-thom", plot = TRUE, title = "")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/testthat/test-bg-cnbd-k.R:31:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.ConditionalExpectedTransactions(params[-1], 32, 1, 16, 32),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:36:1: style: lines should not be more than 80 characters.

​               bgcnbd.PlotFrequencyInCalibration(params, cbs, 7), tolerance = 0.01)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:37:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.PlotFreqVsConditionalExpectedFrequency(params[-1], T.star = 39, cbs, cbs$x.star, 7),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:38:1: style: lines should not be more than 80 characters.

​               bgcnbd.PlotFreqVsConditionalExpectedFrequency(params, T.star = 39, cbs, cbs$x.star, 7), tolerance = 0.01)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:39:1: style: lines should not be more than 80 characters.

# Note: BTYD::bgnbd.PlotRecVsConditionalExpectedFrequency can't handle missing bins, so we can't compare
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:40:1: style: lines should not be more than 80 characters.

​  expect_silent(bgcnbd.PlotRecVsConditionalExpectedFrequency(params, cbs, T.star = 39, cbs$x.star))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:42:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.PlotTrackingInc(params[-1], cbs$T.cal, max(cbs$T.cal) + 32, inc_tracking),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:43:1: style: lines should not be more than 80 characters.

​               bgcnbd.PlotTrackingInc(params, cbs$T.cal, max(cbs$T.cal) + 32, inc_tracking),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:45:1: style: lines should not be more than 80 characters.

​  expect_silent(bgcnbd.PlotTrackingInc(params, cbs$T.cal, max(cbs$T.cal) + 32, inc_tracking,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:47:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.ExpectedCumulativeTransactions(params[-1], 11, 39, 12),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:51:1: style: lines should not be more than 80 characters.

​  expect_equal(BTYD::bgnbd.PlotTrackingCum(params[-1], cbs$T.cal, 32 + 32, cu_tracking),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:69:1: style: lines should not be more than 80 characters.

est_fixed_k <- bgcnbd.EstimateParameters(cbs[, c("x", "t.x", "T.cal", "litt")], k = params[1])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:76:1: style: lines should not be more than 80 characters.

cbs$x.est32 <- bgcnbd.ConditionalExpectedTransactions(params, 32, cbs$x, cbs$t.x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-bg-cnbd-k.R:77:1: style: lines should not be more than 80 characters.

cbs$x.est64 <- bgcnbd.ConditionalExpectedTransactions(params, 64, cbs$x, cbs$t.x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:5:1: style: lines should not be more than 80 characters.

elog <- data.frame(cust = c(1, 1, 1, 1, 1, 2, 3), date = Sys.Date() + c(0, 14, 14, 28, 35, 7, 24))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:6:1: style: lines should not be more than 80 characters.

elog_time <- data.frame(cust = c(1, 1, 1, 1, 1, 2, 3), date = Sys.time() + c(0, 14, 14, 28, 35, 7, 24))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:7:14: style: Words within variable and function names should be separated by '_' rather than '.'.

elog_dt <- as.data.table(elog)
             ^~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:19:1: style: lines should not be more than 80 characters.

​  expect_equal(elog2cbs(elog_time, units = "secs", T.cal = as.character(min(elog_time$date) + 21))[, 1:4],
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:20:1: style: lines should not be more than 80 characters.

​               elog2cbs(elog, units = "days", T.cal = as.character(Sys.Date() + 21))[, 1:4])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:30:1: style: lines should not be more than 80 characters.

​               c("cust", "x", "t.x", "litt", "sales", "first", "T.cal", "T.star", "x.star", "sales.star"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:32:1: style: lines should not be more than 80 characters.

​               c("cust", "x", "t.x", "litt", "first", "T.cal", "T.star", "x.star"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:34:1: style: lines should not be more than 80 characters.

​               c("cust", "x", "t.x", "litt", "first", "T.cal", "T.star", "x.star"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:37:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(elog$cust), nrow(elog2cbs(elog)))
               ^~~~~~~

tests/testthat/test-elog2cbs.R:38:1: style: lines should not be more than 80 characters.

​  expect_equal(uniqueN(elog[elog$date <= T.cal, "cust"]), nrow(elog2cbs(elog, T.cal = T.cal)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:38:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(elog[elog$date <= T.cal, "cust"]), nrow(elog2cbs(elog, T.cal = T.cal)))
               ^~~~~~~

tests/testthat/test-elog2cbs.R:42:1: style: lines should not be more than 80 characters.

​  expect_equal(uniqueN(elog_dt[, .(cust, date)]), sum(cbs$x) + sum(cbs$x.star) + nrow(cbs))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:42:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(elog_dt[, .(cust, date)]), sum(cbs$x) + sum(cbs$x.star) + nrow(cbs))
               ^~~~~~~

tests/testthat/test-elog2cbs.R:47:1: style: lines should not be more than 80 characters.

​  expect_equal(uniqueN(elog_dt[elog_dt$first <= T.cal & date <= T.tot, .(cust, date)]),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:47:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(elog_dt[elog_dt$first <= T.cal & date <= T.tot, .(cust, date)]),
               ^~~~~~~

tests/testthat/test-elog2cbs.R:52:1: style: lines should not be more than 80 characters.

​  expect_equal(elog_s[first <= T.cal & date <= T.cal, sum(sales)], sum(cbs$sales))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:53:1: style: lines should not be more than 80 characters.

​  expect_equal(elog_s[first <= T.cal & date <= T.tot, sum(sales)], sum(cbs$sales) + sum(cbs$sales.star))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:56:1: style: lines should not be more than 80 characters.

cbs <- elog2cbs(elog_s, T.cal = as.character(T.cal), T.tot = as.character(T.tot))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:64:1: style: lines should not be more than 80 characters.

​  expect_equal(elog2cbs(elog, units = "hours")$t.x / (7 * 24), elog2cbs(elog)$t.x)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:65:1: style: lines should not be more than 80 characters.

elog_time <- data.frame(cust = c(1, 1, 1, 1, 1, 2, 3), date = Sys.time() + c(0, 14, 14, 28, 35, 7, 24))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:66:1: style: lines should not be more than 80 characters.

​  expect_equal(elog2cbs(elog, units = "days")[, c(1:4, 6)], elog2cbs(elog_time, units = "secs")[, c(1:4, 6)])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:8:1: style: lines should not be more than 80 characters.

​  expect_silent(BTYDplus:::dc.check.model.params.safe(printnames, params, "foo"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:12:1: style: lines should not be more than 80 characters.

​  expect_silent(BTYDplus:::dc.check.model.params.safe(printnames, params, "foo"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:25:1: style: lines should not be more than 80 characters.

col.names = c("cust", "sampleid", "date", "cds", "sales"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:28:15: style: Variable and function names should be all lowercase.

utils::data(cdnowSummary, package = "BTYD", envir = environment())
              ^~~~~~~~~~~~

tests/testthat/test-helpers.R:29:21: style: Variable and function names should be all lowercase.

​  expect_equal(cum, cdnowSummary$cu.tracking)
                    ^~~~~~~~~~~~

tests/testthat/test-helpers.R:37:1: style: lines should not be more than 80 characters.

​  expect_equal(diff(elog2cum(elog, by = 7, first = TRUE)), elog2inc(elog, by = 7, first = TRUE))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:39:1: style: lines should not be more than 80 characters.

​  expect_equal(tail(elog2cum(elog, by = 1, first = FALSE), 1), nrow(elog) - uniqueN(elog$cust))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:39:77: style: Variable and function names should be all lowercase.

​  expect_equal(tail(elog2cum(elog, by = 1, first = FALSE), 1), nrow(elog) - uniqueN(elog$cust))
                                                                            ^~~~~~~

tests/testthat/test-helpers.R:41:1: style: lines should not be more than 80 characters.

elog <- data.table(cust = c(1, 1, 1, 1, 1, 3, 3), t = c(0, 9, 9, 20, 22, 4, 6))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:51:1: style: lines should not be more than 80 characters.

​  expect_silent(plotTimingPatterns(groceryElog, headers = c("X", "Y"), title = ""))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:52:1: style: lines should not be more than 80 characters.

​  expect_silent(plotTimingPatterns(groceryElog, T.cal = "2006-12-31", title = NULL))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:53:1: style: lines should not be more than 80 characters.

​  expect_silent(plotTimingPatterns(groceryElog, T.cal = "2006-12-31", T.tot = "2007-06-30",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-helpers.R:57:1: style: lines should not be more than 80 characters.

​  expect_silent(plotTimingPatterns(head(groceryElog, 10), T.cal = "2006-12-31", T.tot = "2007-12-30"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:20:1: style: lines should not be more than 80 characters.

est2 <- mbgcnbd.EstimateParameters(cbs[, c("x", "t.x", "T.cal", "litt")], k = 2)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:28:1: style: lines should not be more than 80 characters.

cbs$x.est <- mbgcnbd.ConditionalExpectedTransactions(params, cbs$T.star, cbs$x, cbs$t.x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:47:1: style: lines should not be more than 80 characters.

​  expect_silent(mbgcnbd.PlotTrackingInc(params, cbs$T.cal, max(cbs$T.cal + cbs$T.star), elog2inc(elog, by = 14)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:48:1: style: lines should not be more than 80 characters.

​  expect_silent(mbgcnbd.PlotTrackingCum(params, cbs$T.cal, max(cbs$T.cal + cbs$T.star), elog2cum(elog, by = 14)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:51:1: style: lines should not be more than 80 characters.

mat <- mbgcnbd.PlotFreqVsConditionalExpectedFrequency(params, cbs$T.star, cbs, cbs$x.star, 7)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:55:1: style: lines should not be more than 80 characters.

​  expect_lt(mbgcnbd.ConditionalExpectedTransactions(params, T.star = 32, x = c(0, 1), t.x = c(0, 12), T.cal = 32)[2], 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:56:1: style: lines should not be more than 80 characters.

​  expect_true(mbgcnbd.ConditionalExpectedTransactions(params, T.star = 32, x = 3, t.x = 12, T.cal = 32) !=
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:57:1: style: lines should not be more than 80 characters.

​                mbgcnbd.ConditionalExpectedTransactions(params, T.star = 32, x = 2, t.x = 12, T.cal = 32))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mbg-cnbd-k.R:67:1: style: lines should not be more than 80 characters.

cbs$x.est <- mbgcnbd.ConditionalExpectedTransactions(params, cbs$T.star, cbs$x, cbs$t.x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:17:1: style: lines should not be more than 80 characters.

abe_params$beta <- matrix(c(0.18, -2.5, 0.5, -0.3, -0.2, 0.8), byrow = TRUE, ncol = 2)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:20:1: style: lines should not be more than 80 characters.

abe_draws <- abe.mcmc.DrawParameters(abe_cbs, c("covariate_1", "covariate_2"), mcmc, burnin, thin, chains)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:25:1: style: lines should not be more than 80 characters.

pggg_draws <- pggg.mcmc.DrawParameters(pggg_cbs, mcmc / 10, burnin / 10, thin / 10, chains)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:32:1: style: lines should not be more than 80 characters.

pnbd_xstar_draws1 <- mcmc.DrawFutureTransactions(pnbd_cbs, pnbd_draws, sample_size = size)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:35:1: style: lines should not be more than 80 characters.

pnbd_xstar_draws2 <- mcmc.DrawFutureTransactions(pnbd_cbs, pnbd_draws, sample_size = size)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:37:1: style: lines should not be more than 80 characters.

​  expect_gt(cor(apply(pnbd_xstar_draws2, 2, mean), apply(pnbd_xstar_draws, 2, mean)), 0.95)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:38:1: style: lines should not be more than 80 characters.

​  expect_silent(pnbd_xstar_draws <- mcmc.DrawFutureTransactions(pnbd_cbs, pnbd_draws, T.star = 10))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:46:1: style: lines should not be more than 80 characters.

​  expect_equal(dim(pnbd_xstar_draws3), c((mcmc + burnin - burnin2) * chains / thin, nrow(pnbd_cbs)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:46:42: style: Place a space before left parenthesis, except in a function call.

​  expect_equal(dim(pnbd_xstar_draws3), c((mcmc + burnin - burnin2) * chains / thin, nrow(pnbd_cbs)))
                                         ^

tests/testthat/test-mcmc.R:85:1: style: lines should not be more than 80 characters.

​  expect_equal(mcmc.Expectation(pnbd_draws, 28), mean(pnbd_cbs$x), tolerance = 0.1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:86:1: style: lines should not be more than 80 characters.

x <- mcmc.ExpectedCumulativeTransactions(pnbd_draws, T.cal = pnbd_cbs$T.cal, T.tot = 56, n.periods.final = 56)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mcmc.R:99:1: style: lines should not be more than 80 characters.

BTYD::pnbd.PlotFrequencyInCalibration(unlist(pnbd_params), pnbd_cbs, censor = 7),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-nbd.R:18:1: style: lines should not be more than 80 characters.

cbs$x.est <- nbd.ConditionalExpectedTransactions(params, cbs$T.star, cbs$x, cbs$T.cal)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-ggg-mcmc.R:12:37: style: Words within variable and function names should be separated by '_' rather than '.'.

draws <- pggg.mcmc.DrawParameters(as.data.table(cbs),
                                    ^~~~~~~~~~~~~

tests/testthat/test-pareto-ggg-mcmc.R:13:1: style: lines should not be more than 80 characters.

mcmc = 10, burnin = 0, thin = 1, mc.cores = 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-ggg-mcmc.R:14:1: style: lines should not be more than 80 characters.

param_init = list(r = 1, alpha = 1, s = 1, beta = 1, t = 1, gamma = 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-ggg-mcmc.R:16:1: style: lines should not be more than 80 characters.

mcmc = 100, burnin = 20, thin = 10, chains = 2, mc.cores = 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:9:1: style: lines should not be more than 80 characters.

params$beta <- matrix(c(0.18, -2.5, 0.5, -0.3, -0.2, 0.8), byrow = TRUE, ncol = 2)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:11:1: style: lines should not be more than 80 characters.

​  expect_silent(abe.GenerateData(n = 100, T.cal = 32, T.star = c(16, 32), params))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:21:1: style: lines should not be more than 80 characters.

draws <- abe.mcmc.DrawParameters(as.data.table(cbs), covariates = c("covariate_1"),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:21:36: style: Words within variable and function names should be separated by '_' rather than '.'.

draws <- abe.mcmc.DrawParameters(as.data.table(cbs), covariates = c("covariate_1"),
                                   ^~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:22:1: style: lines should not be more than 80 characters.

mcmc = 10, burnin = 0, thin = 1, mc.cores = 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:25:1: style: lines should not be more than 80 characters.

draws <- abe.mcmc.DrawParameters(cbs, covariates = c("covariate_1", "covariate_2"), mc.cores = 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:28:1: style: lines should not be more than 80 characters.

​  expect_true(all(c("lambda", "mu", "z", "tau") %in% colnames(as.matrix(draws$level_1[[1]]))))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:29:1: style: lines should not be more than 80 characters.

​  expect_true(all(c("log_lambda_intercept", "log_mu_intercept", "log_lambda_covariate_1", "log_mu_covariate_1",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:30:1: style: lines should not be more than 80 characters.

"log_lambda_covariate_2", "log_mu_covariate_2", "var_log_lambda", "cov_log_lambda_log_mu", "var_log_mu") %in%
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:38:1: style: lines should not be more than 80 characters.

​  expect_equal(matrix(est[1:6], ncol = 2, byrow = T), params$beta, tolerance = 0.05)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:41:1: style: lines should not be more than 80 characters.

​  expect_equal(unname(est["var_log_lambda"]), params$gamma[1, 1], tolerance = 0.1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:42:1: style: lines should not be more than 80 characters.

​  expect_equal(unname(est["cov_log_lambda_log_mu"]), params$gamma[1, 2], tolerance = 0.1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:17:16: style: Variable and function names should be all lowercase.

​  expect_equal(uniqueN(sim$elog$cust), n)
               ^~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:30:1: style: lines should not be more than 80 characters.

sim <- pggg.GenerateData(100, 52, c(26, 104), params, date.zero = as.Date("2010-01-01"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:61:37: style: Words within variable and function names should be separated by '_' rather than '.'.

draws <- pnbd.mcmc.DrawParameters(as.data.table(cbs),
                                    ^~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:62:1: style: lines should not be more than 80 characters.

mcmc = 10, burnin = 0, thin = 1, mc.cores = 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:63:1: style: lines should not be more than 80 characters.

param_init = list(r = 1, alpha = 1, s = 1, beta = 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:95:1: style: lines should not be more than 80 characters.

mcmc = 10, burnin = 0, thin = 2, chains = 2,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-mcmc.R:96:1: style: lines should not be more than 80 characters.

use_data_augmentation = FALSE, mc.cores = 1)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-timing.R:17:1: style: lines should not be more than 80 characters.

​  expect_error(k_est_1 <- estimateRegularity(elog, plot = TRUE, min = 60), "sufficient")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-timing.R:21:1: style: lines should not be more than 80 characters.

k_est_3 <- estimateRegularity(elog, method = "mle-minka", plot = TRUE, title = "Plot Title")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-timing.R:22:1: style: lines should not be more than 80 characters.

k_est_4 <- estimateRegularity(elog, method = "mle-thom", plot = TRUE, title = "")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please sign in to comment.