Package 'DEmixR'

Title: Fit Two-Component Normal and Lognormal Mixture Models
Description: Fits, bootstraps, and evaluates two-component normal and lognormal mixture models. Includes diagnostic plots and statistical evaluation of mixture model fits using differential evolution optimization.
Authors: Farrokh Habibzadeh [aut, cre]
Maintainer: Farrokh Habibzadeh <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1
Built: 2026-05-26 07:47:54 UTC
Source: https://github.com/cran/DEmixR

Help Index


Bootstrap mixture parameters

Description

Bootstrap mixture parameters

Usage

bootstrap_mix2(
  fit = NULL,
  x = NULL,
  par = NULL,
  family = NULL,
  B = 1000,
  parametric = TRUE,
  boot_size = NULL,
  parallelType = 0,
  quiet = 2,
  ci_level = 0.95
)

Arguments

fit

fitted object from fit_lognorm2 or fit_norm2

x

numeric vector (if fit not provided)

par

numeric vector of parameters (if fit not provided)

family

"lognormal" or "normal" (if fit not provided)

B

number of bootstrap replicates

parametric

logical, parametric bootstrap if TRUE

boot_size

size or fraction (if between 0 and 1) of bootstrap sample

parallelType

integer for DEoptim/pbapply parallelism

quiet

0/1/2 for verbosity

ci_level

confidence level

Value

list with cleaned bootstrap estimates, central tendency, and CI


Evaluate initial parameter values for mixture fitting

Description

Evaluate initial parameter values for mixture fitting

Usage

evaluate_init(
  par_init,
  x,
  family = c("lognormal", "normal"),
  lower = NULL,
  upper = NULL,
  pgtol = 1e-08
)

Arguments

par_init

numeric vector of initial parameters

x

numeric vector of data

family

"lognormal" or "normal"

lower

numeric vector of lower bounds

upper

numeric vector of upper bounds

pgtol

numeric, gradient tolerance for optim

Value

list with success flag, optimized parameters, log-likelihood, and convergence


Fit 2-component lognormal mixture

Description

Fit 2-component lognormal mixture

Usage

fit_lognorm2(x, ...)

Arguments

x

numeric vector of data to fit

...

additional arguments passed to .fit_mix2_core

Value

list with fitted parameters and metrics


Fit 2-component normal mixture

Description

Fit 2-component normal mixture

Usage

fit_norm2(x, ...)

Arguments

x

numeric vector of data to fit

...

additional arguments passed to .fit_mix2_core

Value

list with fitted parameters and metrics


Preliminary diagnostic plots

Description

Preliminary diagnostic plots

Usage

prelim_plots(
  x,
  which = c("hist"),
  hist_bins = 60,
  col_hist = "grey85",
  col_density = "darkorange",
  col_qq = "grey60",
  col_line = "darkorange"
)

Arguments

x

numeric vector

which

character vector: "hist", "qq", "pp", "logqq"

hist_bins

number of bins for histogram

col_hist

color for histogram

col_density

color for density line in histogram

col_qq

color for qq points

col_line

color for lines in "qq", "pp", "logqq" plots

Value

no return value, called for side effects (generating plots)


Select best mixture model (lognormal or normal) based on BIC

Description

Select best mixture model (lognormal or normal) based on BIC

Usage

select_best_mixture(x, n_runs = 1, NP = 50, itermax = 10000, quiet = 2)

Arguments

x

numeric vector

n_runs

number of DEoptim runs

NP

population size for DEoptim

itermax

maximum iterations

quiet

verbosity

Value

list with best fit, all fits, and BICs