Skip to content

Commit

Permalink
fix mcmc.ExpectedCumulativeTransactions for Pareto/NBD (Abe) (#57)
Browse files Browse the repository at this point in the history
* - fix `mcmc.ExpectedCumulativeTransactions` for Pareto/NBD (Abe) with covariates (#55)
- add ability to provide covariates to `abe.generateData`

* fix code style
  • Loading branch information
mplatzer authored Mar 13, 2017
1 parent 2e82c02 commit 5178098
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 22 deletions.
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.1.1
Version: 1.1.2
Authors@R: person("Michael", "Platzer", email = "michael.platzer@gmail.com", 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 NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.1.2
- fix `mcmc.ExpectedCumulativeTransactions` for Pareto/NBD (Abe) with covariates (#55)
- add ability to provide covariates to `abe.generateData`

1.1.1
- added `sales.x` to `elog2cbs` output, which sums over sales in calibration, but excludes initial transaction (thanks to msinjin for the suggestion)

Expand Down
35 changes: 24 additions & 11 deletions R/mcmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ mcmc.plotPActiveDiagnostic <- function(cbs, xstar, title = "Diagnostic Plot for
#' @param x Number of transactions for which probability is calculated. May also
#' be a vector.
#' @param sample_size Sample size for estimating the probability distribution.
#' @param covariates (optional) Matrix of covariates, for Pareto/NBD (Abe)
#' model, passed to \code{\link{abe.GenerateData}} for simulating data.
#' @return \eqn{P(X(t)=x)}. If either \code{t} or \code{x} is a vector, then the
#' output will be a vector as well. If both are vectors, the output will be a
#' matrix.
Expand All @@ -218,7 +220,7 @@ mcmc.plotPActiveDiagnostic <- function(cbs, xstar, title = "Diagnostic Plot for
#' mcmc = 200, burnin = 100, thin = 20, chains = 1) # short MCMC to run demo fast
#' mcmc.pmf(param.draws, t = 52, x = 0:6)
#' mcmc.pmf(param.draws, t = c(26, 52), x = 0:6)
mcmc.pmf <- function(draws, t, x, sample_size = 10000) {
mcmc.pmf <- function(draws, t, x, sample_size = 10000, covariates = NULL) {
cohort_draws <- as.matrix(draws$level_2)
nr_of_draws <- nrow(cohort_draws)
# use posterior mean
Expand All @@ -238,7 +240,8 @@ mcmc.pmf <- function(draws, t, x, sample_size = 10000) {
p["cov_log_lambda_log_mu"],
p["var_log_mu"]),
ncol = 2)
abe.GenerateData(n = n, T.cal = 0, T.star = unique(t), params = params)$cbs
abe.GenerateData(n = n, T.cal = 0, T.star = unique(t), params = params,
covariates = covariates)$cbs
}
}))
pmf <- sapply(1:length(t), function(idx) {
Expand Down Expand Up @@ -302,6 +305,8 @@ mcmc.Expectation <- function(draws, t, sample_size = 10000) {
#' @param n.periods.final Number of time periods in the calibration and holdout
#' periods.
#' @param sample_size Sample size for estimating the probability distribution.
#' @param covariates (optional) Matrix of covariates, for Pareto/NBD (Abe)
#' model, passed to \code{\link{abe.GenerateData}} for simulating data.
#' @return Numeric vector of expected cumulative total repeat transactions by
#' all customers.
#' @export
Expand All @@ -314,7 +319,8 @@ mcmc.Expectation <- function(draws, t, sample_size = 10000) {
#' # weeks, with every eigth week being reported.
#' mcmc.ExpectedCumulativeTransactions(param.draws,
#' T.cal = cbs$T.cal, T.tot = 104, n.periods.final = 104/8, sample_size = 1000)
mcmc.ExpectedCumulativeTransactions <- function(draws, T.cal, T.tot, n.periods.final, sample_size = 10000) {
mcmc.ExpectedCumulativeTransactions <- function(draws, T.cal, T.tot, n.periods.final,
sample_size = 10000, covariates = NULL) {
if (any(T.cal < 0) || !is.numeric(T.cal))
stop("T.cal must be numeric and may not contain negative numbers.")
if (length(T.tot) > 1 || T.tot < 0 || !is.numeric(T.tot))
Expand All @@ -333,13 +339,14 @@ mcmc.ExpectedCumulativeTransactions <- function(draws, T.cal, T.tot, n.periods.f
} else if (model == "abe") {
p <- as.list(cohort_draws[i, ])
params <- list()
params$beta <- matrix(p[grepl("^log\\_", names(p))], byrow = TRUE, ncol = 2)
params$gamma <- matrix(c(p["var_log_lambda"],
params$beta <- matrix(as.numeric(p[grepl("^log\\_", names(p))]), byrow = TRUE, ncol = 2)
params$gamma <- matrix(as.numeric(c(p["var_log_lambda"],
p["cov_log_lambda_log_mu"],
p["cov_log_lambda_log_mu"],
p["var_log_mu"]),
p["var_log_mu"])),
ncol = 2)
elog <- abe.GenerateData(n = n, T.cal = T.tot, T.star = 0, params = params)$elog
elog <- abe.GenerateData(n = n, T.cal = T.tot, T.star = 0, params = params,
covariates = covariates)$elog
}
setDT(elog)
elog$cust <- paste0(elog$cust, "_", i)
Expand Down Expand Up @@ -389,6 +396,8 @@ mcmc.ExpectedCumulativeTransactions <- function(draws, T.cal, T.tot, n.periods.f
#' @param ymax Upper boundary for y axis.
#' @param sample_size Sample size for estimating the probability distribution.
#' See \code{\link{mcmc.ExpectedCumulativeTransactions}}.
#' @param covariates (optional) Matrix of covariates, for Pareto/NBD (Abe)
#' model, passed to \code{\link{abe.GenerateData}} for simulating data.
#' @return Matrix containing actual and expected cumulative repeat transactions.
#' @export
#' @seealso \code{\link{mcmc.PlotTrackingInc}}
Expand All @@ -407,10 +416,11 @@ mcmc.ExpectedCumulativeTransactions <- function(draws, T.cal, T.tot, n.periods.f
mcmc.PlotTrackingCum <- function(draws, T.cal, T.tot, actual.cu.tracking.data,
xlab = "Week", ylab = "Cumulative Transactions",
xticklab = NULL, title = "Tracking Cumulative Transactions",
ymax = NULL, sample_size = 10000) {
ymax = NULL, sample_size = 10000, covariates = NULL) {

actual <- actual.cu.tracking.data
expected <- mcmc.ExpectedCumulativeTransactions(draws, T.cal, T.tot, length(actual), sample_size = sample_size)
expected <- mcmc.ExpectedCumulativeTransactions(draws, T.cal, T.tot, length(actual),
sample_size = sample_size, covariates = covariates)

dc.PlotTracking(actual = actual, expected = expected, T.cal = T.cal,
xlab = xlab, ylab = ylab, title = title,
Expand Down Expand Up @@ -445,6 +455,8 @@ mcmc.PlotTrackingCum <- function(draws, T.cal, T.tot, actual.cu.tracking.data,
#' @param ymax Upper boundary for y axis.
#' @param sample_size Sample size for estimating the probability distribution.
#' See \code{\link{mcmc.ExpectedCumulativeTransactions}}.
#' @param covariates (optional) Matrix of covariates, for Pareto/NBD (Abe)
#' model, passed to \code{\link{abe.GenerateData}} for simulating data.
#' @return Matrix containing actual and expected incremental repeat
#' transactions.
#' @export
Expand All @@ -464,10 +476,11 @@ mcmc.PlotTrackingCum <- function(draws, T.cal, T.tot, actual.cu.tracking.data,
mcmc.PlotTrackingInc <- function(draws, T.cal, T.tot, actual.inc.tracking.data,
xlab = "Week", ylab = "Transactions",
xticklab = NULL, title = "Tracking Weekly Transactions",
ymax = NULL, sample_size = 10000) {
ymax = NULL, sample_size = 10000, covariates = NULL) {

actual <- actual.inc.tracking.data
expected_cum <- mcmc.ExpectedCumulativeTransactions(draws, T.cal, T.tot, length(actual), sample_size = sample_size)
expected_cum <- mcmc.ExpectedCumulativeTransactions(draws, T.cal, T.tot, length(actual),
sample_size = sample_size, covariates = covariates)
expected <- BTYD::dc.CumulativeToIncremental(expected_cum)

dc.PlotTracking(actual = actual, expected = expected, T.cal = T.cal,
Expand Down
24 changes: 20 additions & 4 deletions R/pareto-nbd-abe.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ abe.mcmc.DrawParameters <- function(cal.cbs, covariates = c(), mcmc = 2500, burn
#' @param T.star Length of holdout period. This may be a vector.
#' @param params A list of model parameters: \code{beta} and \code{gamma}.
#' @param date.zero Initial date for cohort start. Can be of class character, Date or POSIXt.
#' @param covariates Provide matrix of customer covariates. If NULL then random covariate values between [-1,1] are drawn.
#' @return List of length 2:
#' \item{\code{cbs}}{A data.frame with a row for each customer and the summary statistic as columns.}
#' \item{\code{elog}}{A data.frame with a row for each transaction, and columns \code{cust}, \code{date} and \code{t}.}
Expand All @@ -273,7 +274,7 @@ abe.mcmc.DrawParameters <- function(cal.cbs, covariates = c(), mcmc = 2500, burn
#' data <- abe.GenerateData(n = 2000, T.cal = 32, T.star = 32, params)
#' cbs <- data$cbs # customer by sufficient summary statistic - one row per customer
#' elog <- data$elog # Event log - one row per event/purchase
abe.GenerateData <- function(n, T.cal, T.star, params, date.zero = "2000-01-01") {
abe.GenerateData <- function(n, T.cal, T.star, params, date.zero = "2000-01-01", covariates = NULL) {

# set start date for each customer, so that they share same T.cal date
T.cal.fix <- max(T.cal)
Expand All @@ -285,9 +286,24 @@ abe.GenerateData <- function(n, T.cal, T.star, params, date.zero = "2000-01-01")
params$beta <- matrix(params$beta, nrow = 1, ncol = 2)

nr_covars <- nrow(params$beta)
covars <- matrix(c(rep(1, n), runif( (nr_covars - 1) * n, -1, 1)), nrow = n, ncol = nr_covars)
colnames(covars) <- paste("covariate", 0:(nr_covars - 1), sep = "_")
colnames(covars)[1] <- "intercept"
if (!is.null(covariates)) {
# ensure that provided covariates are in matrix format, with intercept
covars <- covariates
if (is.data.frame(covars)) covars <- as.matrix(covars)
if (!is.matrix(covars)) covars <- matrix(covars, ncol = 1, dimnames = list(NULL, "covariate_1"))
if (!all(covars[, 1] == 1)) covars <- cbind("intercept" = rep(1, nrow(covars)), covars)
if (is.null(colnames(covars)) & ncol(covars) > 1)
colnames(covars)[-1] <- paste("covariate", 1:(nr_covars - 1), sep = "_")
if (nr_covars != ncol(covars))
stop("provided number of covariate columns does not match implied covariate number by parameter `beta`")
if (n != nrow(covars))
covars <- covars[sample(1:nrow(covars), n, replace = TRUE), ]
} else {
# simulate covariates, if not provided
covars <- matrix(c(rep(1, n), runif( (nr_covars - 1) * n, -1, 1)), nrow = n, ncol = nr_covars)
colnames(covars) <- paste("covariate", 0:(nr_covars - 1), sep = "_")
colnames(covars)[1] <- "intercept"
}

# sample log-normal distributed parameters lambda/mu for each customer
thetas <- exp( (covars %*% params$beta) + mvtnorm::rmvnorm(n, mean = c(0, 0), sigma = params$gamma))
Expand Down
5 changes: 4 additions & 1 deletion man/abe.GenerateData.Rd

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

5 changes: 4 additions & 1 deletion man/mcmc.ExpectedCumulativeTransactions.Rd

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

5 changes: 4 additions & 1 deletion man/mcmc.PlotTrackingCum.Rd

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

5 changes: 4 additions & 1 deletion man/mcmc.PlotTrackingInc.Rd

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

5 changes: 4 additions & 1 deletion man/mcmc.pmf.Rd

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

48 changes: 47 additions & 1 deletion tests/testthat/test-pareto-nbd-abe.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,50 @@ context("mcmc")
test_that("Pareto/NBD (Abe) MCMC", {
skip_on_cran()

# test basic data simulation
n <- 100
params <- list()
params$beta <- matrix(c(0.18, -2.5, 0.5, -0.3, -0.2, 0.8), byrow = TRUE, ncol = 2)
params$gamma <- matrix(c(0.05, 0.1, 0.1, 0.2), ncol = 2)
expect_silent(abe.GenerateData(n, 36, 36, params,
covariates = matrix(c(rnorm(n), runif(n)), ncol = 2)))
expect_silent(abe.GenerateData(n, 36, 36, params,
covariates = matrix(c(rnorm(n), runif(n)), ncol = 2,
dimnames = list(NULL, c("x1", "x2")))))
expect_error(abe.GenerateData(n, 36, 36, params,
covariates = matrix(c(rnorm(n)), ncol = 1,
dimnames = list(NULL, c("x1")))),
"covariate columns")
expect_error(abe.GenerateData(n, 36, 36, params,
covariates = matrix(c(rnorm(n), runif(n), runif(n)), ncol = 3,
dimnames = list(NULL, c("x1", "x2", "x3")))),
"covariate columns")
params$beta <- params$beta[1:2, ]
expect_silent(abe.GenerateData(n, 36, 36, params, covariates = rnorm(n)))
expect_silent(abe.GenerateData(n, 36, 36, params, covariates = matrix(rnorm(n), ncol = 1,
dimnames = list(NULL, "x1"))))

# generate artificial Pareto/NBD (Abe) with 2 covariates
set.seed(1)
params <- list()
params$beta <- matrix(c(0.18, -2.5, 0.5, -0.3, -0.2, 0.8), byrow = TRUE, ncol = 2)
params$gamma <- matrix(c(0.05, 0.1, 0.1, 0.2), ncol = 2)
expect_silent(abe.GenerateData(n = 100, T.cal = 32, T.star = c(16, 32), params))
n <- 5000
sim <- abe.GenerateData(n,
round(runif(n, 36, 96) / 12) * 12,
36,
params,
"2010-01-01")
# TODO: test param recoverability with covars being provided to abe.GenerateData
# covars <- matrix(c(runif(n, 0, 10), runif(n, 10, 20)), ncol = 2,
# dimnames = list(NULL, c("x1", "x2")))

cbs <- sim$cbs
expect_true(all(c("intercept", "covariate_1", "covariate_2") %in% names(cbs)))

# test basic parameter estimation
draws <- abe.mcmc.DrawParameters(as.data.table(cbs),
mcmc = 10, burnin = 0, thin = 1, mc.cores = 1)
draws <- abe.mcmc.DrawParameters(as.data.table(cbs), covariates = c("covariate_1"),
mcmc = 10, burnin = 0, thin = 1, mc.cores = 1)

Expand Down Expand Up @@ -57,4 +86,21 @@ test_that("Pareto/NBD (Abe) MCMC", {
expect_true(all(cbs$x.star == round(cbs$x.star)))
expect_true(all(cbs$palive >= 0 & cbs$palive <= 1))

# check tracking plots
inc <- elog2inc(sim$elog)
mat <- mcmc.PlotTrackingInc(draws,
T.cal = cbs$T.cal,
T.tot = max(cbs$T.cal + cbs$T.star),
actual.inc.tracking.data = inc,
covariates = cbs[, c("covariate_1", "covariate_2")])
mat.sum <- apply(mat, 1, sum)
expect_equal(mat[1], mat[2], tolerance = 0.1)
cum <- elog2cum(sim$elog)
mat <- mcmc.PlotTrackingCum(draws,
T.cal = cbs$T.cal,
T.tot = max(cbs$T.cal + cbs$T.star),
actual.cu.tracking.data = cum,
covariates = cbs[, c("covariate_1", "covariate_2")])
expect_equal(mat[, ncol(mat) - 1], mat[, ncol(mat) - 1], tolerance = 0.1)

})

2 comments on commit 5178098

@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:28:1: style: lines should not be more than 80 characters.

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

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

​               c("cust", "x", "t.x", "litt", "sales", "sales.x", "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 < date & first <= T.cal & date <= T.cal, sum(sales)], sum(cbs$sales.x))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:54: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:57: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:65: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:66: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:67: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:12:1: style: lines should not be more than 80 characters.

covariates = matrix(c(rnorm(n), runif(n)), ncol = 2)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

covariates = matrix(c(rnorm(n), runif(n)), ncol = 2,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dimnames = list(NULL, c("x1", "x2")))))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dimnames = list(NULL, c("x1")))),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

covariates = matrix(c(rnorm(n), runif(n), runif(n)), ncol = 3,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dimnames = list(NULL, c("x1", "x2", "x3")))),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

​  expect_silent(abe.GenerateData(n, 36, 36, params, covariates = matrix(rnorm(n), ncol = 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dimnames = list(NULL, "x1"))))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:32: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:40:1: style: lines should not be more than 80 characters.

# TODO: test param recoverability with covars being provided to abe.GenerateData
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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

tests/testthat/test-pareto-nbd-abe.R:49: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:50: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:50: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:51: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:54: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:57: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:58: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:59: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:67: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:70: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:71: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-abe.R:95:1: style: lines should not be more than 80 characters.

covariates = cbs[, c("covariate_1", "covariate_2")])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

covariates = cbs[, c("covariate_1", "covariate_2")])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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:28:1: style: lines should not be more than 80 characters.

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

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

​               c("cust", "x", "t.x", "litt", "sales", "sales.x", "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 < date & first <= T.cal & date <= T.cal, sum(sales)], sum(cbs$sales.x))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-elog2cbs.R:54: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:57: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:65: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:66: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:67: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:12:1: style: lines should not be more than 80 characters.

covariates = matrix(c(rnorm(n), runif(n)), ncol = 2)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

covariates = matrix(c(rnorm(n), runif(n)), ncol = 2,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dimnames = list(NULL, c("x1", "x2")))))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dimnames = list(NULL, c("x1")))),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

covariates = matrix(c(rnorm(n), runif(n), runif(n)), ncol = 3,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dimnames = list(NULL, c("x1", "x2", "x3")))),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

​  expect_silent(abe.GenerateData(n, 36, 36, params, covariates = matrix(rnorm(n), ncol = 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dimnames = list(NULL, "x1"))))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-pareto-nbd-abe.R:32: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:40:1: style: lines should not be more than 80 characters.

# TODO: test param recoverability with covars being provided to abe.GenerateData
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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

tests/testthat/test-pareto-nbd-abe.R:49: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:50: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:50: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:51: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:54: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:57: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:58: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:59: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:67: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:70: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:71: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-abe.R:95:1: style: lines should not be more than 80 characters.

covariates = cbs[, c("covariate_1", "covariate_2")])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

covariates = cbs[, c("covariate_1", "covariate_2")])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.