Package: densityratio 0.1.1

densityratio: Distribution comparison through density ratio estimation

This package provides functionality to directly estimate the ratio of two probability distributions from samples from these distributions without estimating the densities separately. Density ratio estimation serves many purposes, for example, prediction, outlier detection, change-point detection in time-series, importance weighting under domain adaptation (i.e., sample selection bias) and evaluation of synthetic data utility. The rationale behind these use-cases is that differences between two data distributions can be captured in the ratio their density ratio, which is estimated over the entire multivariate space of the data. Computationally intensive code is executed in `C++` using `Rcpp` and `RcppArmadillo`. The package provides good default hyperparameters that can be optimized in cross-validation (we do recommend understanding those parameters before using `densityratio` in practice). Multiple density ratio estimation methods are implemented, such as unconstrained least-squares importance fitting (`ulsif()`), Kullback-Leibler importance estimation procedure (`kliep()`), ratio of estimated densities (`naive()`), ratio of estimated densities after dimension reduction (`naivesubspace()`), and least-squares heterodistributional subspace search (`lhss()`; experimental).

Authors:Thom Volker [aut, cre], Carlos Gonzalez Poses [ctb], Erik-Jan van Kesteren [ctb]

densityratio_0.1.1.tar.gz
densityratio_0.1.1.zip(r-4.5)densityratio_0.1.1.zip(r-4.4)densityratio_0.1.1.zip(r-4.3)
densityratio_0.1.1.tgz(r-4.4-x86_64)densityratio_0.1.1.tgz(r-4.4-arm64)densityratio_0.1.1.tgz(r-4.3-x86_64)densityratio_0.1.1.tgz(r-4.3-arm64)
densityratio_0.1.1.tar.gz(r-4.5-noble)densityratio_0.1.1.tar.gz(r-4.4-noble)
densityratio_0.1.1.tgz(r-4.4-emscripten)densityratio_0.1.1.tgz(r-4.3-emscripten)
densityratio.pdf |densityratio.html
densityratio/json (API)

# Install 'densityratio' in R:
install.packages('densityratio', repos = c('https://thomvolker.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/thomvolker/densityratio/issues

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
Datasets:

On CRAN:

4.15 score 6 stars 17 scripts 10 exports 33 dependencies

Last updated 2 months agofrom:e34ca87ae3. Checks:OK: 1 NOTE: 8. Indexed: yes.

TargetResultDate
Doc / VignettesOKNov 01 2024
R-4.5-win-x86_64NOTENov 01 2024
R-4.5-linux-x86_64NOTENov 01 2024
R-4.4-win-x86_64NOTENov 01 2024
R-4.4-mac-x86_64NOTENov 01 2024
R-4.4-mac-aarch64NOTENov 01 2024
R-4.3-win-x86_64NOTENov 01 2024
R-4.3-mac-x86_64NOTENov 01 2024
R-4.3-mac-aarch64NOTENov 01 2024

Exports:distancekernel_gaussiankliepkmmlhssnaiveplot_bivariateplot_univariatespectralulsif

Dependencies:clicolorspacefansifarverggplot2gluegtableisobandlabelinglatticelifecyclemagrittrMASSMatrixmgcvmunsellnlmepbapplypillarpkgconfigquadprogR6RColorBrewerRcppRcppArmadilloRcppProgressrlangscalestibbleutf8vctrsviridisLitewithr

Readme and manuals

Help Manual

Help pageTopics
Bivariate plotcreate_bivariate_plot
Indivual univariate plotcreate_univariate_plot
denominator_datadenominator_data
Create a Gram matrix with squared Euclidean distances between observations in the input matrix 'X' and the input matrix 'Y'distance
A histogram of density ratio estimatesdr.histogram plot.kliep plot.lhss plot.naivedensityratio plot.naivesubspacedensityratio plot.spectral plot.ulsif
Create gaussian kernel gram matrix from distance matrixkernel_gaussian
Kullback-Leibler importance estimation procedurekliep
Kernel mean matching approach to density ratio estimationkmm
Least-squares heterodistributional subspace searchlhss
Naive density ratio estimationnaive
numerator_datanumerator_data
Single permutationpermute permute.kliep permute.lhss permute.naivedensityratio permute.naivesubspacedensityratio permute.spectral permute.ulsif
Densityratio in bidimensional plotplot_bivariate
Scatter plot of density ratios and individual variablesplot_univariate
Obtain predicted density ratio values from a 'kliep' objectpredict.kliep
Obtain predicted density ratio values from a 'lhss' objectpredict.lhss
Obtain predicted density ratio values from a 'naivedensityratio' objectpredict.naivedensityratio
Obtain predicted density ratio values from a 'spectral' objectpredict.spectral
Obtain predicted density ratio values from a 'ulsif' objectpredict.ulsif
Print a 'kliep' objectprint.kliep
Print a 'lhss' objectprint.lhss
Print a 'naivedensityratio' objectprint.naivedensityratio
Print a 'spectral' objectprint.spectral
Print a 'summary.kliep' objectprint.summary.kliep
Print a 'summary.lhss' objectprint.summary.lhss
Print a 'summary.naivedensityratio' objectprint.summary.naivedensityratio
Print a 'summary.spectral' objectprint.summary.spectral
Print a 'summary.ulsif' objectprint.summary.ulsif
Print a 'ulsif' objectprint.ulsif
Spectral series based density ratio estimationspectral
Extract summary from 'kliep' object, including two-sample significance test for homogeneity of the numerator and denominator samplessummary.kliep
Extract summary from 'lhss' object, including two-sample significance test for homogeneity of the numerator and denominator samplessummary.lhss
Extract summary from 'naivedensityraito' object, including two-sample significance test for homogeneity of the numerator and denominator samplessummary.naivedensityratio
Extract summary from 'naivesubspacedensityraito' object, including two-sample significance test for homogeneity of the numerator and denominator samplessummary.naivesubspacedensityratio
Extract summary from 'spectral' object, including two-sample significance test for homogeneity of the numerator and denominator samplessummary.spectral
Extract summary from 'ulsif' object, including two-sample significance test for homogeneity of the numerator and denominator samplessummary.ulsif
Unconstrained least-squares importance fittingulsif