densratio: Estimate Density Ratio p(x)/q(y)

Description Usage Arguments Value Examples

Description

Estimate Density Ratio p(x)/q(y)

Usage

1
2
densratio(x, y, method = c("uLSIF", "KLIEP"), sigma = "auto",
  lambda = "auto", kernel_num = 100, fold = 5, verbose = TRUE)

Arguments

x

numeric vector or matrix. Data from a numerator distribution p(x).

y

numeric vector or matrix. Data from a denominator distribution q(y).

method

"uLSIF"(default) or "KLIEP".

sigma

positive numeric vector. Search range of Gaussian kernel bandwidth.

lambda

positive numeric vector. Search range of regularization parameter for uLSIF.

kernel_num

positive integer. Number of kernels.

fold

positive integer. Numer of the folds of cross validation for KLIEP.

verbose

logical(default TRUE).

Value

densratio object that contains a function to compute estimated density ratio.

Examples

1
2
3
4
5
6
7
8
9
x <- rnorm(200, mean = 1, sd = 1/8)
y <- rnorm(200, mean = 1, sd = 1/2)

result <- densratio(x, y)

new_x <- seq(0, 2, by = 0.06)
estimated_density_ratio <- result$compute_density_ratio(new_x)

plot(new_x, estimated_density_ratio, pch=19)

densratio documentation built on May 9, 2019, 1:03 a.m.