Skip to contents

Conditional Density Estimation with Heteroskedasticity

Usage

lnr_heteroskedastic_density(
  data,
  formula,
  mean_lnr,
  var_lnr,
  mean_lnr_args = NULL,
  var_lnr_args = NULL,
  density_args = NULL
)

Arguments

data

A dataframe to train a learner / learners on.

formula

A regression formula to use inside this learner.

mean_lnr

A learner (function) passed in to be trained on the data with the given formula and then used to predict conditional means for provided newdata.

var_lnr

A learner (function) passed in to be trained on the squared error from the mean_lnr on the given data and then used to predict the expected variance for the density distribution of the outcome centered around the predicted conditional mean in the output.

mean_lnr_args

Extra arguments to be passed to the mean_lnr

var_lnr_args

Extra arguments to be passed to the var_lnr

density_args

Extra arguments to be passed to the kernel density smoother stats::density, especially things like bw for specifying the smoothing bandwidth. See ?stats::density.

Value

a closure (function) that produces density estimates at the newdata given according to the fit model.