# NOT RUN {
## create 'Mix' object
geomMix <- Mix("geom", discrete = TRUE, w = c(0.1, 0.6, 0.3), prob = c(0.8, 0.2, 0.4))
## create random data based on 'Mix' object (gives back 'rMix' object)
set.seed(1)
geomRMix <- rMix(1000, obj = geomMix)
## create 'datMix' object for estimation
# explicit function giving the estimate for the j^th moment of the
# mixing distribution, needed for Hankel.method "explicit"
explicit.fct.geom <- function(dat, j){
1 - ecdf(dat)(j - 1)
}
## generating 'datMix' object
geom.dM <- RtoDat(geomRMix, Hankel.method = "explicit",
Hankel.function = explicit.fct.geom)
## function for penalization w/o scaling
pen <- function(j, n){
(j*log(n))/(sqrt(n))
}
## estimate determinants w/o scaling
set.seed(1)
geomdets_pen <- nonparamHankel(geom.dM, pen.function = pen, j.max = 5,
scaled = FALSE)
plot(geomdets_pen, main = "Three component geometric mixture")
## function for penalization with scaling
pen <- function(j, n){
j*log(n)
}
## estimate determinants using the same penalty with scaling
geomdets_pen <- nonparamHankel(geom.dM, pen.function = pen, j.max = 5,
scaled = TRUE)
plot(geomdets_pen, main = "Three component geometric mixture")
# }
Run the code above in your browser using DataLab