dc.InputCheck: Check the inputs to functions that use this common pattern

Description Usage Arguments Details Value See Also

View source: R/dc.R

Description

A bunch of functions whose names start with pnbd take a set of four parameters as their first argument, and then a set of vectors or scalars such as x or T.cal as their subsequent arguments. This function started out as pnbd.InputCheck() and it was meant to run input checks for any number of such subsequent vector arguments, as long as they all met the same requirements as x, t.x and T.cal in pnbd.LL: meaning, the length of the longest of these vectors is a multiple of the lengths of all others, and all vectors are numeric and positive.

Usage

1
dc.InputCheck(params, func, printnames = c("r", "alpha", "s", "beta"), ...)

Arguments

params

If used by pnbd.[...] functions, Pareto/NBD parameters – a vector with r, alpha, s, and beta, in that order. See pnbd.LL. If used by bgnbd.[...] functions, BG/NBD parameters – a vector with r, alpha, a, and b, in that order. See bgnbd.LL. If used by bgbb.[...] functions, BG/BB parameters – a vector with alpha, beta, gamma, and delta, in that order. See bgbb.LL. If used by spend.[...] functions, a vector of gamma-gamma parameters – p, q, and gamma, in that order. See spend.LL.

func

Function calling dc.InputCheck

printnames

a string vector with the names of parameters to pass to dc.check.model.params

...

other arguments

Details

With an extra argument, printnames, pnbd.InputCheck() could also accommodate input checks for functions whose names start with bgbb, bgnbd, and spend so it was basically useful everywhere. That's when it became dc.InputCheck(). params can have any length as long as that length is the same as the length of printnames, so dc.InputCheck() can probably handle mixtures of distributions for modeling BTYD behavior that are not yet implemented.

By other arguments ... here we mean a bunch of named vectors that are used by functions that call dc.InputCheck, such as x, t.x, T.cal, etc. The standard rules for vector operations apply - if they are not of the same length, shorter vectors will be recycled (start over at the first element) until they are as long as the longest vector. Vector recycling is a good way to get into trouble. Keep vectors to the same length and use single values for parameters that are to be the same for all calculations. If one of these parameters has a length greater than one, the output will be a vector of probabilities.

Value

If all is well, a data frame with everything you need in it, with nrow() equal to the length of the longest vector in ...

See Also

pnbd.LL pnbd.ConditionalExpectedTransactions


BTYD documentation built on Nov. 18, 2021, 1:10 a.m.