Retrieve specific elements from an ALE object with the get() generic.
Requests for stats = 'conf_regions' or stats = 'conf_sig' require
p-values and raise an error if none are available, even with silent = TRUE.
Value
Regardless of the requested data, all calls to get() on an ALE object 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. If, however, the y outcome is not categorical or only one category of multiple possibilities is specified using the
catsargument, 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 nod1sublist but only a list of the ALE data as described for the next level. Ifsimplify = FALSE, bothd1andd2sublists will always be returned; the empty sublist will beNULLor an empty list.
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.binorvar.ceilwherevaris the name of a variable (column): For non-numeric x,var.binis the value of each of the ALE categories. For numeric x,var.ceilis 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 anvar1byvar2interaction, bothvar1.binandvar2.bincolumns are returned (orvar1.ceilorvar2.ceilfor numericvar1orvar2). *.n: the number of rows of data in each bin represented byvar.binorvar.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_meanby default or.y_medianifboot_centre = 'median'. Regardless, both.y_meanand.y_medianare returned as columns here. *.y_lo,.y_hi: the lower and upper confidence intervals, respectively, for the bootstrapped.yvalue based on theboot_alphaargument 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_hiare 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.itare from 1 toboot_it(number of bootstrap iterations specified in theALE()constructor. *varwherevaris the name of a variable (column): For non-numeric x,varis the value of each of the ALE categories. For numeric x,varis the value of the upper bound (ceiling) of each ALE bin. They are otherwise similar to their meanings described forwhat = 'ale'above. *.nand.y: Same as forwhat = 'ale'.what = 'ale'(default) andstats = 'estimate'A list with elements
d1andd2with the value of each ALE statistic. Each row represents one variable or interaction. The tibble has the following columns: *term: The variables or columns for the 1D or 2D ALE statistic. *aled,aler_min,aler,aler_max,naled,naler_min,naler,naler_max: the respective ALE statistic for the variable or interaction.what = 'ale'(default) andstatsis one or more values inc('aled', 'aler_min', 'aler', 'aler_max', 'naled', 'naler_min', 'naler', 'naler_max')A list with elements
d1andd2with the distribution value of the single requested ALE statistic. Each elementd1andd2is a tibble. Each row represents one statistic for one variable or interaction. The tibble has the following columns: *term: Same as forstats = 'estimate'. *statistic: The requested ALE statistic(s). *estimate,mean,median: The average of the bootstrapped value of the requested statistic.estimateis equal to eithermeanormediandepending on theboot_centreargument in theALE()constructor. If ALE is not bootstrapped, thenestimate,mean, andmedianare equal. *conf.low,conf.high: the lower and upper confidence intervals, respectively, for the bootstrapped statistic based on theboot_alphaargument in theALE()constructor. If ALE is not bootstrapped, thenestimate,conf.low, andconf.highare equal.what = 'ale'(default) andstats = 'all'A list with elements
d1andd2with 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. Thus, the data structure and columns are identical as for single statistics above, except that all available ALE statistics are returned.what = 'ale'(default) andstats = 'conf_regions'A list with elements
d1andd2with the confidence regions for the requested variables and interactions. Each element is a list with the requestedd1andd2sub-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'Identical structure as
stats = 'conf_regions'except that the elements are filtered for the terms (variables or interactions) that have statistically significant confidence regions exceeding the threshold of the inner ALER band, specifically, at leastobj@params$aler_alpha[2]of the rows of data. Seevignette("ale-statistics")for details.
Method usage
get(obj, x_cols = NULL, what = "ale", ..., exclude_cols = NULL, stats = NULL, cats = NULL, ale_centre = "median", simplify = TRUE, silent = FALSE)Method arguments
obj: ALE object from which to retrieve elements.x_cols,exclude_cols: character, list, or formula. Columns names and interaction terms fromobjrequested in one of the specialx_colsformats. The default value ofNULLforx_colsretrieves 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 either "ale" (default) or "boot_data". To retrieve ALE statistics, see thestatsargument....: not used. Inserted to require explicit naming of subsequent arguments.stats: character. Retrieve ALE statistics. Named statistics are returned in the requested order within each term. Ifstatsis specified, thenwhatmust be left at the default ("ale"). Otherwise,get()errors ifstatsis specified andwhathas some other value. 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.ale_centre: Same as in documentation forALEPlots()simplify: logical(1). IfTRUE(default), recursively remove empty elements and zero-row data frames, then promote the sole member of each remaining list. Nonempty data frames, ggplots, and other objects that are not simple lists are kept intact. If no objects remain, returnNULL. IfFALSE, a complex but consistent list structure will be returned; this might be preferred for programmatic and non-interactive use.silent: See documentation forresolve_x_cols()
