The do()
function facilitates easy replication for
randomization tests and bootstrapping (among other things). Part of what
makes this particularly useful is the ability to cull from the objects
produced those elements that are useful for subsequent analysis.
cull_for_do
does this culling. It is generic, and users
can add new methods to either change behavior or to handle additional
classes of objects.
Details
When do(n) * expression
is evaluated, expression
is evaluated n
times to produce a list of n
result objects.
cull_for_do
is then applied to each element of this list to
extract from it the information that should be stored. For example,
when applied to a object of class "lm"
,
the default cull_for_do
extracts the coefficients, coefficient
of determinism, an the estimate for the variance, etc.
Examples
Clock_auction |> model_train(price ~ resample(bidders)) |>
R2() |> trials(times=10)
#> .trial n k Rsquared F adjR2 p df.num df.denom
#> 1 1 32 1 0.0272469030 0.84030274 -0.0051782002 0.3661674 1 30
#> 2 2 32 1 0.0005793999 0.01739208 -0.0327346201 0.8959057 1 30
#> 3 3 32 1 0.0107625143 0.32638819 -0.0222120686 0.5717847 1 30
#> 4 4 32 1 0.0408865813 1.27888674 0.0089161340 0.2665108 1 30
#> 5 5 32 1 0.0314786869 0.97505403 -0.0008053569 0.3308309 1 30
#> 6 6 32 1 0.0107889079 0.32719734 -0.0221847951 0.5713109 1 30
#> 7 7 32 1 0.0053843910 0.16240619 -0.0277694626 0.6896307 1 30
#> 8 8 32 1 0.0845673859 2.77139086 0.0540529654 0.1057257 1 30
#> 9 9 32 1 0.0194090616 0.59379689 -0.0132773031 0.4466069 1 30
#> 10 10 32 1 0.0110352039 0.33475015 -0.0219302893 0.5669256 1 30