varkernel: Perform a two-dimensional kernel density estimation for an...

View source: R/varkernel.R

varkernelR Documentation

Perform a two-dimensional kernel density estimation for an outcome variable and a given influencing variable. The function produces a matrix of the estimated density (z) of an outcome variable (y) and an observed variable expected to influence the outcome variable (x). As the density function restricts the shape of the kernel to a bivariate normal kernel, it looks slightly different compared to the scatter plot estimates in the uncertainty::varscatter() function. Density surface plot of an influencing variable (x) and an outcome variable (y). The legend shows the value for the estimated density (z).

Description

Perform a two-dimensional kernel density estimation for an outcome variable and a given influencing variable.

The function produces a matrix of the estimated density (z) of an outcome variable (y) and an observed variable expected to influence the outcome variable (x). As the density function restricts the shape of the kernel to a bivariate normal kernel, it looks slightly different compared to the scatter plot estimates in the uncertainty::varscatter() function. Density surface plot of an influencing variable (x) and an outcome variable (y). The legend shows the value for the estimated density (z).

Usage

varkernel(
  in_var,
  out_var,
  xlab = "Influencing variable",
  ylab = "Outcome variable"
)

Arguments

in_var

is a vector of observations of a given influencing variable corresponding to another list with observed values of an outcome variable out_var.

out_var

is a vector of observed values of an outcome variable corresponding to another list with observations of a given influencing variable in_var.

xlab

is a label for the influencing variable in_var on the x axis, the default label is "Influencing variable".

ylab

is a label for the outcome variable out_var on the y axis, the default label is "Outcome variable".

Examples

in_var <- sample(x = 1:50, size = 20, replace = TRUE)
out_var <- sample(x = 1000:5000, size = 20, replace = TRUE)
varkernel(in_var, out_var)


CWWhitney/uncertainty documentation built on June 14, 2022, 10:21 p.m.