0

I have discrete count data indicating the number of successes in 10 binomial trials for a pilot sample of 46 cases. (Larger samples will follow once I have the analysis set up.) The zero class (no successes in 10 trials) is missing, i.e. each datum is an integer value between 1 and 10 inclusive. I want to fit a truncated binomial distribution with no zero class, in order to estimate the underlying probability p. I can do this adequately on an Excel spreadsheet using least squares with Solver, but because I want to calculate bootstrap confidence intervals on p, I am trying to implement it in R.

Frankly, I am struggling to understand how to code this. This is what I have so far:

d <- detections.data$x

# load required packages
library(fitdistrplus)
library(truncdist)
library(mc2d)

ptruncated.binom <- function(q, p) {
  ptrunc(q, "binom", a = 1, b = Inf, p)
}
dtruncated.binom <- function(x, p) {
  dtrunc(x, "binom", a = 1, b = Inf, p)
}

fit.tbin <- fitdist(d, "truncated.binom", method="mle", start=list(p=0.1))

I have had lots of error messages which I have solved by guesswork, but the latest one has me stumped and I suspect I am totally misunderstanding something.

Error in checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg, : 'start' must specify names which are arguments to 'distr'.<

I think this means I must specify starting values for x in dtrunc and q in ptrunc, but I am really unclear what they should be.

Any help would be very gratefully received.

  • The zero class is not really missing : if you have, say, 3 successes out of 10 trials, then that's 10-3 = 7 failures. So it's a usual binomial process, there's not need for zero-truncation. – meriops Dec 11 '20 at 15:16
  • Thanks, but it seems I didn't explain that very well. Each case represents the composite result of 10 trials (1,2,3...10 successes). Cases where there were zero successes over 10 trials are missing from the dataset. These are biological data, and each case is sufficiently different that there cannot be any argument for pooling all the trials into one dataset. I have slightly edited my question above to clarify this. – Jonathan Reynolds Dec 11 '20 at 16:53

0 Answers0