Description Usage Arguments Details Value References Examples
step_lencode_bayes
creates a specification of a recipe step that
will convert a nominal (i.e. factor) predictor into a single set of
scores derived from a generalized linear model estimated using
Bayesian analysis.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
recipe 
A recipe object. The step will be added to the sequence of operations for this recipe. 
... 
One or more selector functions to choose variables.
For 
role 
Not used by this step since no new variables are created. 
trained 
A logical to indicate if the quantities for preprocessing have been estimated. 
outcome 
A call to 
options 
A list of options to pass to 
verbose 
A logical to control the default printing by

mapping 
A list of tibble results that define the
encoding. This is 
skip 
A logical. Should the step be skipped when the
recipe is baked by 
id 
A character string that is unique to this step to identify it. 
x 
A 
For each factor predictor, a generalized linear model is fit to the outcome and the coefficients are returned as the encoding. These coefficients are on the linear predictor scale so, for factor outcomes, they are in logodds units. The coefficients are created using a no intercept model and, when two factor outcomes are used, the logodds reflect the event of interest being the first level of the factor.
For novel levels, a slightly timmed average of the coefficients is returned.
A hierarchical generalized linear model is fit using
rstanarm::stan_glmer()
and no intercept via
1 
where the ...
include the family
argument (automatically
set by the step) as well as any arguments given to the options
argument to the step. Relevant options include chains
, iter
,
cores
, and arguments for the priors (see the links in the
References below). prior_intercept
is the argument that has the
most effect on the amount of shrinkage.
An updated version of recipe
with the new step added
to the sequence of existing steps (if any). For the tidy
method, a tibble with columns terms
(the selectors or
variables for encoding), level
(the factor levels), and
value
(the encodings).
MicciBarreca D (2001) "A preprocessing scheme for highcardinality categorical attributes in classification and prediction problems," ACM SIGKDD Explorations Newsletter, 3(1), 2732.
Zumel N and Mount J (2017) "vtreat: a data.frame Processor for Predictive Modeling," arXiv:1611.09477
"Hierarchical Partial Pooling for Repeated Binary Trials" https://tinyurl.com/stanpooling
"Prior Distributions for 'rstanarmâ€œ Models" https://tinyurl.com/stanpriors
"Estimating Generalized (Non)Linear Models with GroupSpecific
Terms with rstanarm
" https://tinyurl.com/stanglmgrouped
1 2 3 4 5 6 7 8 9 10 11 12 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.