naive | R Documentation |
The naive approach creates separate kernel density estimates for
the numerator and the denominator samples, and then evaluates their
ratio for the denominator samples. For multivariate data, the density ratio
is computed after a orthogonal linear transformation, such that the new
variables can be treated as independent. To reduce the dimensionality of
the PCA solution, one can set the number of components by setting the
m
parameter to an integer value smaller than the number of variables.
naive(
df_numerator,
df_denominator,
m = NULL,
bw = "SJ",
kernel = "gaussian",
n = 2L^11,
...
)
df_numerator |
|
df_denominator |
|
m |
|
bw |
the smoothing bandwidth to be used. See stats::density for more information. |
kernel |
the kernel to be used. See stats::density for more information. |
n |
|
... |
further arguments passed to stats::density |
naivedensityratio
object
stats::density()
set.seed(123)
# Fit model
dr <- naive(numerator_small, denominator_small)
# Inspect model object
dr
# Obtain summary of model object
summary(dr)
# Plot model object
plot(dr)
# Plot density ratio for each variable individually
plot_univariate(dr)
# Plot density ratio for each pair of variables
plot_bivariate(dr)
# Predict density ratio and inspect first 6 predictions
head(predict(dr))
# Fit model with custom parameters
naive(numerator_small, denominator_small, m=2, kernel="epanechnikov")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.