# NOT RUN {
data(children)
# convert the data to vector:
children.obs <- unlist(children)
# explicit function giving the estimate for the j^th moment of the
# mixing distribution, needed for Hankel.method "explicit"
explicit.pois <- function(dat, j){
mat <- matrix(dat, nrow = length(dat), ncol = j) -
matrix(0:(j-1), nrow = length(dat), ncol = j, byrow = TRUE)
return(mean(apply(mat, 1, prod)))
}
# define the MLE function:
MLE.pois <- function(dat) mean(dat)
# construct a 'datMix' object:
children.dM <- datMix(children.obs, dist = "pois", discrete = TRUE,
Hankel.method = "explicit",
Hankel.function = explicit.pois,
theta.bound.list = list(lambda = c(0, Inf)),
MLE.function = MLE.pois)
# define the penalty:
pen <- function(j, n) j * log(n)
# complexity estimation:
# }
# NOT RUN {
set.seed(0)
det_sca_pen <- nonparamHankel(children.dM, j.max = 5, scaled = TRUE,
B = 1000, pen.function = pen)
plot(det_sca_pen, main = "Non-parametric Hankel method for Children dataset")
# }
Run the code above in your browser using DataLab