# NOT RUN {
### generating 'Mix' object
normLocMix <- Mix("norm", discrete = FALSE, w = c(0.3, 0.4, 0.3), mean = c(10, 13, 17),
sd = c(1, 1, 1))
### generating 'rMix' from 'Mix' object (with 1000 observations)
set.seed(0)
normLocRMix <- rMix(1000, normLocMix)
### generating 'datMix' from 'R' object
## generate list of parameter bounds
norm.bound.list <- list("mean" = c(-Inf, Inf), "sd" = c(0, Inf))
## generate MLE functions
# for "mean"
MLE.norm.mean <- function(dat) mean(dat)
# for "sd" (the sd function uses (n-1) as denominator)
MLE.norm.sd <- function(dat){
sqrt((length(dat) - 1) / length(dat)) * sd(dat)
}
# combining the functions to a list
MLE.norm.list <- list("MLE.norm.mean" = MLE.norm.mean,
"MLE.norm.sd" = MLE.norm.sd)
## generating 'datMix' object
normLoc.dM <- RtoDat(normLocRMix, theta.bound.list = norm.bound.list,
MLE.function = MLE.norm.list)
### complexity and parameter estimation
# }
# NOT RUN {
set.seed(0)
res <- mix.lrt(normLoc.dM, B = 30)
plot(res)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab