# NOT RUN {
## create 'Mix' object
poisMix <- Mix("pois", discrete = TRUE, w = c(0.45, 0.45, 0.1), lambda = c(1, 5, 10))
## create random data based on 'Mix' object (gives back 'rMix' object)
set.seed(1)
poisRMix <- rMix(1000, obj = poisMix)
## create 'datMix' object for estimation
# generate list of parameter bounds
poisList <- list("lambda" = c(0, Inf))
# generate MLE function
MLE.pois <- function(dat){
mean(dat)
}
# generate function needed for estimating the j^th moment of the
# mixing distribution via Hankel.method "explicit"
explicit.pois <- function(dat, j){
res <- 1
for (i in 0:(j-1)){
res <- res*(dat-i)
}
return(mean(res))
}
# generating 'datMix' object
pois.dM <- RtoDat(poisRMix, theta.bound.list = poisList, MLE.function = MLE.pois,
Hankel.method = "explicit", Hankel.function = explicit.pois)
## complexity and parameter estimation
# }
# NOT RUN {
set.seed(1)
res <- paramHankel(pois.dM)
plot(res)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab