Skip to content

DEmixR

0.3.0Package record

Fit Two-Component Normal and Lognormal Mixture Models

0packages depend
2.5Kdownloads / year
92.3%test coverage
13/13flavors OK

Overview

About

Fits, bootstraps, and evaluates two-component normal and lognormal mixture models. Parameters are searched within data-derived bounds by differential-evolution global optimization, as implemented in the 'DEoptim' package (Mullen, Ardia, Gil, Windover and Cline, 2011) doi:10.18637/jss.v040.i06, followed by a local 'L-BFGS-B' refinement step via optim(). Also provides preliminary diagnostic plots, diagnostic plots for fitted mixtures, automatic normal-versus-lognormal model selection by the Bayesian or Akaike information criterion, and parametric or nonparametric bootstrap confidence intervals for the fitted parameters.

Changes in 0.3.0

This release corrects the numerical objective, checks optimizer convergence,

adds input validation, diagnostics and new plots. Several changes alter

numerical results; see "Changes that can alter results".

Changes that can alter results

  • **Exact log-likelihood.** The objective is now evaluated by log-sum-exp. Version 0.2.0 computed sum(log(density + 1e-12)), which capped the contribution of every observation whose mixture density was below 1e-12. The previous objective used density_floor = 1e-12; this option is no longer part of the public API. Log-likelihoods, AIC, BIC and, for data with extreme observations, the fitted parameters can differ from 0.2.0. Note that the floor acted as an implicit robustification: with the exact likelihood a single extreme observation can attract a component of its own. This is reported by the new diagnostics (see below).
Show all changes in 0.3.0Hide the rest of the changes in 0.3.0
  • **L-BFGS-B convergence is checked.** A local refinement is accepted only if optim() reports convergence code 0. Otherwise a warning is given and the unrefined DE solution is returned (fit$source == "DEoptim_nolocal"). fit$convergence and fit$message now describe the returned candidate (0.2.0 always reported the run started from the DE solution).
  • **Defaults of n_runs.** fit_norm2(), fit_lognorm2() now default to n_runs = 10 (was 20). select_best_mixture() now uses the same defaults as the fitting functions, n_runs = 10, NP = 100 (was 1 and 50).
  • **Bootstrap.** Replicates are accepted only if the refinement converged; default bounds are recomputed from every bootstrap sample (as for the original fit); central is now the **median for both families** (0.2.0: mean for normal, median for lognormal; use center = "mean"); the mean and median are always returned.
  • **P-P plot.** The "pp" panel of prelim_plots() is now a proper normal P-P plot. In 0.2.0 it plotted the sorted empirical-CDF values against the observation index, which is the same straight line for any data set.

New features

  • mix2_bounds() (exported) returns the data-derived parameter bounds; the scale limits and the range of the mixing proportion are controlled with scale_range and p_range. The bounds are documented: the mean bounds are *not* split at the median.
  • Input validation: x must be finite (no NA/NaN/Inf) with at least 10 observations and non-zero variance; a warning is given for n < 50; user bounds must have length 5, be finite and ordered, and stay inside the model.
  • Fit objects store source, local_convergence, the bounds (lower, upper), settings, de_logLik (log-likelihood of each DE run) and diagnostics. Warnings and print()/summary() notes flag solutions on a bound of the parameter box and components whose expected size (sum of posterior probabilities) is below min_comp_n (default 5).
  • scale_ratio argument (default 0 = off): a Hathaway (1985)-type relative constraint min(s1, s2) / max(s1, s2) >= scale_ratio, enforced by a quadratic penalty; the reported log-likelihood is the exact one. It is inherited by bootstrap_mix2() from the fit.
  • bootstrap_mix2(refit = "de") repeats a differential-evolution search for every replicate (de_control); refit = "local" (default) is the fast local refit of 0.2.0 and is documented as not propagating multimodality. Failed replicates are counted (n_failed).
  • plot(fit, which = "pit") and which = "qq" compare the data with the fitted mixture. prelim_plots() gains "logpp".
  • select_best_mixture(criterion = "BIC" | "AIC"); errors of an individual family fit are reported instead of being swallowed.

Bug fixes and documentation

  • parallelType = 1 requires the parallelly package because DEoptim does; it is listed under Suggests and a clear error is given if missing. The parallel objective is now self-contained for PSOCK workers, so internal DEmixR functions are not required on the worker search path. The numerical objective and the meanings of parallelType are unchanged. DEoptim uses 0 = serial, 1 = parallel, and 2 = foreach.
  • In bootstrap_mix2(), parallelType is the number of forked processes (values 0 and 1 run serially; ignored on Windows); the documentation of 0.2.0 described it as the DEoptim setting.
  • Documentation states that the search is bounded and that the result is not an unrestricted maximum-likelihood estimate; the lognormal m/s are meanlog/sdlog; Q-Q/P-P panels are exploratory.
  • Test suite extended (validation, likelihood, boundary diagnostics, non-convergence handling, bootstrap failure handling, reproducibility).

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 2.1 min · r-release-macos-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 0.3.0
README· In the repository, left out of the releaseVignettesYes · 1 · dynamicNEWSYes · 100% structured · mentions 0.3.0Citation fileNoWebsitenot declared in DESCRIPTION
Description cites a JSS article
Help pages
14 (1 internal)
Examples that run
69%9 run in a plain check · 4 only when donttest examples are enabled (R CMD check --as-cran)
Exported functions with examples
100%
Documented parameters
100%
Return-value docs
100%
Help pages citing references
7%

Downloads

2.5K
CRAN downloads in the past year
Rank #11,130 · ~7/day · ~212/mo
Daily download trend is not available in this view yet.
44130 days
96690 days
2.5K1 year
Compare downloads with other packages →
Also on76 r2u9 autocran

Repository

0Stars
0Forks
0Open issues
0Open PRs
2Releases
5Commits
1Commit identities
biostatisticsdifferential-evolutionmixture-modelsrr-packa
5 commits · Last activity 2026-09-25
Responsiveness
not measured
PracticesBeta

3 development-tooling and community-health practices detected across 2 families in the upstream repository

Checks run against github.com/fhabibzadeh/demixr on 2026-10-25.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Research and citation (1)
CITATION.cff
How this is detected·Detection ruleset v4 (2026-10-20)

Dependencies

Declared dependencies
6 external dependencies (excludes base and recommended)

Installing DEmixR adds 2 packages (1 with compiled code, 87 KB of source tarballs). Heaviest: DEoptim 64 KB, pbapply 23 KB.

Depends (1)
R >= 4.0.0
Imports (5)
DEoptimpbapplygraphicsstatsutils
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

People & History

People (1)
Author, Maintainer since 0.1.1 (2025)
Releases (3)

Pick two releases to compare their code metrics.

  • 0.3.0Latest
    record
    2026-09-25 · current release · diff ↗ ·
    added 1 export
    mix2_bounds
  • 0.2.0
    record
    2026-08-02 · diff ↗
  • R
    R 4.6.0 released · 2026-04-24
  • 0.1.1
    record
    2025-09-27
  • R
    R 4.5.0 released · 2025-04-11

Package metadata

First published
2025-09-27
Total releases
3 / 1 yrs
License
MIT + file LICENSE OSI
Minimum R
≥ 4.0.0
Download size
221 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("DEmixR")
Habibzadeh, F. (2026). DEmixR: Fit Two-Component Normal and Lognormal Mixture Models (Version 0.3.0) [Computer software]. https://doi.org/10.32614/CRAN.package.DEmixR

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

The repository also keeps a CITATION.cff.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for DEmixR version 0.3.0 [Data set]. HJJB, LLC. Data release v2026-10-26. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-26, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy