diff options
author | Justin Bedo <cu@cua0.org> | 2016-08-30 10:48:41 +1000 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2016-08-30 10:48:41 +1000 |
commit | d3ef79883035c6db3c24002b958c5beed1aee257 (patch) | |
tree | 3b74c05b1229e3408ec225e0051d83da98d26199 | |
parent | d483c1112e838440f332efece783b20d980d42af (diff) |
check for 0 counts
-rw-r--r-- | R/pmt.R | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -12,7 +12,10 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -pmt <- function(a, b, two.sided=F) { +pmt <- function(a, b) { + if(any(a == 0) | any(b == 0)) + stop("cannot handle 0 counts") + ce <- function(mu){ pt1 <- mapply(function(xa, mu, rho) logsumexp(cumsum(log(((1 + rho) * (xa - (0:xa-1))/(2 * mu))))), a, mu, rho) pt2 <- mapply(function(xb, mu, rho) logsumexp(cumsum(log((2*mu*rho) / ((1 + rho)*(xb + (1:100)))))), b, mu, rho) |