# \donttest{
## Simulate data:
list.comp <- list(f = "norm", g = "norm")
list.param <- list(f = c(mean = 4, sd = 1), g = c(mean = 7, sd = 0.5))
sim.data <- rsimmix(n = 400, unknownComp_weight = 0.9, list.comp, list.param)$mixt.data
## Estimate mixture weight and location shift parameters in real-life:
list.comp <- list(f = NULL, g = "norm")
list.param <- list(f = NULL, g = c(mean = 7, sd = 0.5))
estim <- BVdk_estimParam(data = sim.data, method = "L-BFGS-B",
comp.dist = list.comp, comp.param = list.param)
## Estimation of the second-order moment of the known component distribution:
m2_knownComp <- mean(rnorm(n = 1000000, mean = 7, sd = 0.5)^2)
hat_s2 <- (1/estim[1]) * (mean(sim.data^2) - ((1-estim[1])*m2_knownComp)) - estim[2]^2
## Estimated variance of variance estimator related to the unknown symmetric component density:
BVdk_ML_varCov_estimators(data = sim.data, hat_w = estim[1], hat_loc = estim[2],
hat_var = hat_s2, comp.dist = list.comp, comp.param = list.param)
# }
Run the code above in your browser using DataLab