# NOT RUN {
data(hiv)
npobj <- npmle(hiv, family = tdist(df=6), maxiter = 25)
### Generate Binomial data with Beta mixing distribution
n <- 3000
theta <- rbeta(n, shape1 = 2, shape2 = 10)
ntrials <- rpois(n, lambda = 10)
x <- rbinom(n, size = ntrials, prob = theta)
### Estimate mixing distribution
dd <- cbind(x,ntrials)
npest <- npmle(dd, family = binomial, maxiter = 25)
### compare with true mixture cdf
tt <- seq(1e-4,1 - 1e-4, by = .001)
plot(npest, lwd = 2)
lines(tt, pbeta(tt, shape1 = 2, shape2 = 10), lwd = 2, lty = 2)
# }
Run the code above in your browser using DataCamp Workspace