## 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=140, unknownComp_weight=0.9, comp.dist=list.comp, comp.param=list.param)
## Estimate the location shift and mixture weight parameters in real-life setting:
list.comp <- list(f = NULL, g = 'norm')
list.param <- list(f = NULL, g = c(mean = 7, sd = 0.5))
estimators <- BVdk_estimParam(data = sim.data[['mixt.data']], method = "L-BFGS-B",
comp.dist = list.comp, comp.param = list.param)
## Estimate the variance of the two estimators (first mixture weight, then location shift):
BVdk_varCov_estimators(data = sim.data[['mixt.data']], loc = estimators[2], p = estimators[1],
comp.dist = list.comp, comp.param = list.param)
Run the code above in your browser using DataLab