conclude() is the terminal step of the pipeline. It resolves the
method variant, runs the implementation, and returns a cld_exec S7 object.
Arguments
- .x
A
test_lazyormodel_lazyobject produced byprepare_test()orprepare_model()(optionally followed byvia()).- ...
Currently unused.
Value
A cld_exec S7 object with the following slots:
@dataThe raw return value of the
fndefined inbaseline()orvariant(). Its structure depends on the implementation — see the documentation of the stat function (e.g.?TTEST) for what to expect.@cld_metaA list of pipeline metadata:
$var_idThe Variable Mapper object passed to
define_model().$processedThe processed model output from
model_processor(). The same object received as.procinside thefn.$stat_nameThe human-readable test or model name.
$methodThe variant name used.
"default"when novia()was called.$data_nameThe name of the data frame, if resolvable.
Writing print functions
The print argument of baseline() and variant() receives a cld_exec
object as x. Read your output from x@data:
baseline(
fn = function(.proc, .mu = 0) { ... },
print = function(x, ...) {
dat = x@data
# render dat
invisible(x)
}
)Otherwise, when the base S7 class dispatches print() elsewhere, it is inherited
without writing print from baseline() / variant()
Writing tidy functions
Prefer implementing auto_tidy() on your result class when fn returns
a class_stat_infer subclass. Use making_tidy() only when fn
intentionally returns a non-class_stat_infer object.
For example:
making_tidy(TTEST, x_by) %<-% method_tidy(
default = function(.x, ...) {
dat = .x@data
# return a tibble
}
)Examples
sleep |>
define_model(x_by(extra, group)) |>
prepare_test(TTEST) |>
conclude()
#>
#> == Model =======================================================================
#>
#> Variable Mapper : x_by
#> Args : extra | group
#> x_vars : 1
#> by_vars : 1
#>
#> == T-Test ======================================================================
#>
#> -- Summary ---------------------------------------------------------------------
#>
#> ──────────────────────────────────────────
#> group estimate t_stat df p_val
#> ──────────────────────────────────────────
#> group -1.580 -1.861 17.780 0.079
#> ──────────────────────────────────────────
#>
#>
#> -- Confidence Interval ---------------------------------------------------------
#>
#> ─────────────────────────────
#> group lower_95 upper_95
#> ─────────────────────────────
#> group -3.365 0.206
#> ─────────────────────────────
#>
#>
sleep |>
define_model(x_by(extra, group)) |>
prepare_test(TTEST) |>
via("boot", n = 2000) |>
conclude()
#>
#> == Model =======================================================================
#>
#> Variable Mapper : x_by
#> Args : extra | group
#> x_vars : 1
#> by_vars : 1
#>
#> == T-Test · boot ===============================================================
#>
#> ============================== Bootstrapped T-test =============================
#>
#>
#> -- Summary ---------------------------------------------------------------------
#>
#> Warning: running command 'tput cols' had status 2
#> ---------------------------------
#> CI : [-3.1605, -0.0598]
#> n_reps : 2000
#> ---------------------------------
#>
#>
mtcars |>
define_model(rel(mpg, wt)) |>
prepare_model(LINEAR_REG) |>
conclude()
#>
#> == Model =======================================================================
#>
#> Variable Mapper : rel
#> Args : mpg ; wt
#> x_vars : 1
#> resp_vars : 1
#>
#> == Linear Regression ===========================================================
#>
#> -- Coefficients ----------------------------------------------------------------
#>
#> ──────────────┬───────────────────────────────────────────
#> term │ estimate std_error statistic p_value
#> ──────────────┼───────────────────────────────────────────
#> (Intercept) │ 6.047 0.309 19.590 <0.001
#> mpg │ -0.141 0.015 -9.559 <0.001
#> ──────────────┴───────────────────────────────────────────
#>
#>
#> -- Model Fit -------------------------------------------------------------------
#>
#> Warning: running command 'tput cols' had status 2
#> ------------------------------------------------------
#> R Squared : 0.75 F-statistic : 91.38
#> Adj. R Squared : 0.74 df1 : 1
#> Sigma : 0.49 df2 : 30
#> n : 32 p-value : <0.001
#> df (residual) : 30 :
#> ------------------------------------------------------
#>
#>