Retrieve specific elements from an ALE
object.
Arguments
- obj
ALE object from which to retrieve elements.
- x_cols, exclude_cols
character, list, or formula. Columns names and interaction terms from
obj
requested in one of the specialx_cols
formats. The default value ofNULL
forx_cols
retrieves all available data of the output requested inwhat
. See details in the documentation forresolve_x_cols()
.- what
character(1). What kind of output is requested. Must be one (and only one) of
c('ale', 'boot_data')
. Default is'ale'
. Ifstats
is specified andwhat = 'ale'
, then ALE statistics are retrieved. Otherwise,get()
errors ifstats
is specified andwhat
has some other value.- ...
not used. Inserted to require explicit naming of subsequent arguments.
- stats
character(1). Retrieve statistics. If
stats
is specified, thenwhat
must be'ale'
. See the return value details below for valid values forstats
.- cats
character. Optional category names to retrieve if the ALE is for a categorical y outcome model.
- simplify
logical(1). If
TRUE
(default), the results will be simplified to the simplest structure possible to give the requested results.- silent
See documentation for
resolve_x_cols()
Value
Regardless of the requested data, all get.ALE()
have a common structure:
If more than one category of the y outcome is returned, then the top level is a list named by each category. However, the y outcome is not categorical or only one category of multiple possibilities is specified using the
cats
argument, then the top level never has categories, regardless of the value ofsimplify
.The next level (or top level if there are zero or one category) is a list with one or two levels:
d1
: 1D ALE elements.d2
: 2D ALE elements. However, if elements of only one dimension (either 1D or 2D) are requested andsimplify = TRUE
(default), the empty list is eliminated and the level is skipped to provide only the elements present. For example, if only 1D ALE data is requested, then there will be nod1
sublist but only a list of the ALE data as described for the next level. Ifsimplify = FALSE
, bothd1
andd2
sublists will always be returned; the empty sublist will beNULL
.
For the
d1
sublist, there is no further hierarchy: the returned data is as described below. For thed2
sublist representingvar1
byvar2
interactions, the next level is a named list of allvar1
elements. This level in turn consists of a named list ofvar2
elements with the actual data as described below. For example, for ALE data,result <- get(obj, list(d1 = "var1", d2 = list(c("var1", "var2"))))
would returnresult
as a list where the 1D ALE data is inresult$d1$var1
and the 2D ALE data inresult$d2$var1$var2
.
While all results follow the general structure just described, the specific type of data returned depends on the values of the what
and stats
arguments:
what = 'ale'
(default) andstats = NULL
(default)A list whose elements, named by each requested x variable, are each a tibble. The rows each represent one ALE bin. The tibble has the following columns: *
var.bin
orvar.ceil
wherevar
is the name of a variable (column): For non-numeric x,var.bin
is the value of each of the ALE categories. For numeric x,var.ceil
is the value of the upper bound (ceiling) of each ALE bin. The first "bin" of numeric variables represents the minimum value. For 2D ALE with anvar1
byvar2
interaction, bothvar1.bin
andvar2.bin
columns are returned (orvar1.ceil
orvar2.ceil
for numericvar1
orvar2
). *.n
: the number of rows of data in each bin represented byvar.bin
orvar.ceil
. For numeric x, the first bin contains all data elements that have exactly the minimum value of x. This is often 1, but might be more than 1 if more than one data element has exactly the minimum value. *.y
: the ALE function value calculated for that bin. For bootstrapped ALE, this is the same as.y_mean
by default or.y_median
ifboot_centre = 'median'
. Regardless, both.y_mean
and.y_median
are returned as columns here. *.y_lo
,.y_hi
: the lower and upper confidence intervals, respectively, for the bootstrapped.y
value based on theboot_alpha
argument in theALE()
constructor.what = 'boot_data'
andstats = NULL
(default)A list whose elements, named by each requested x variable, are each a tibble. These are the data from which
.y_mean
,.y_median
,.y_lo
, and.y_hi
are summarized whenwhat = 'ale'
. The rows each represent one ALE bin for a specified bootstrap iteration. The tibble has the following columns: *.it
: The bootstrap iteration. Iteration 0 represents the ALE calculations on the full dataset; the remaining values of.it
are from 1 toboot_it
(number of bootstrap iterations specified in theALE()
constructor. *var
wherevar
is the name of a variable (column): For non-numeric x,var
is the value of each of the ALE categories. For numeric x,var
is the value of the upper bound (ceiling) of each ALE bin. They are otherwise similar to their meanings described forwhat = 'ale'
above. *.n
and.y
: Same as forwhat = 'ale'
.what = 'ale'
(default) andstats = 'estimate'
A list with elements
d1
andd2
with the value of each ALE statistic. Each row represents one variable or interaction. The tibble has the following columns: *term
orterm1
andterm2
: The variable or column for the 1D (term
) or 2D (term1
byterm2
) ALE statistic. *aled
,aler_min
,aler_max
,naled
,naler_min
,naler_max
: the respective ALE statistic for the variable or interaction.what = 'ale'
(default) andstats
is one value inc('aled', 'aler_min', 'aler_max', 'naled', 'naler_min', 'naler_max')
A list with elements
d1
andd2
with the distribution value of the single requested ALE statistic. Each elementd1
andd2
is a tibble. Each row represents one variable or interaction. The tibble has the following columns: *term
orterm1
andterm2
: Same as forstats = 'estimate'
. *estimate
,mean
,median
: The average of the bootstrapped value of the requested statistic.estimate
is equal to eithermean
ormedian
depending on theboot_centre
argument in theALE()
constructor. If ALE is not bootstrapped, thenestimate
,mean
, andmedian
are equal. *conf.low
,conf.high
: the lower and upper confidence intervals, respectively, for the bootstrapped statistic based on theboot_alpha
argument in theALE()
constructor. If ALE is not bootstrapped, thenestimate
,conf.low
, andconf.high
are equal.what = 'ale'
(default) andstats = 'all'
A list with elements
d1
andd2
with the distribution values of all available ALE statistics for the requested variables and interactions. Whereas thestats = 'aled'
(for example) format returns data for a single statistic,stats = 'all'
returns all statistics for the requested variables. Each element is a list with the requestedd1
andd2
sub-elements as described in the general structure above. Each data element is a tibble. Each row represents one ALE statistic. The tibble has the following columns: *term
orterm1
andterm2
: Same as forstats = 'estimate'
. *estimate
,mean
,median
: Same as above for individual ALE statistics. *conf.low
,conf.high
: Same as above for individual ALE statistics.what = 'ale'
(default) andstats = 'conf_regions'
A list with elements
d1
andd2
with the confidence regions for the requested variables and interactions. Each element is a list with the requestedd1
andd2
sub-elements as described in the general structure above. Each data element is a tibble with confidence regions for a single variable or interaction. For an explanation of the columns, seevignette('ale-statistics')
.what = 'ale'
(default) andstats = 'conf_sig'
A list with elements
d1
andd2
filtered for the statistically significant confidence regions for the requested variables and interactions. Each element is a tibble. Each row is a single statistically significant confidence region. If there are no statistically significant confidence regions at all, an empty tibble is returned. For an explanation of the columns, seevignette('ale-statistics')
.