Skip to contents

This function returns a trimmed COVLMC from which cached data have been removed.

Usage

# S3 method for covlmc
trim(ct, keep_model = FALSE, ...)

Arguments

ct

a context tree.

keep_model

specifies whether to keep the internal models (or not)

...

additional arguments for the trim function.

Value

a trimmed context tree.

Details

Called with keep_model set to FALSE (default case), the trimming is maximal and reduces further usability of the model. In particular loglikelihood.covlmc() cannot be used for new data, contexts.covlmc() do not support model extraction, and simulate.covlmc(), metrics.covlmc() and prune.covlmc() cannot be used at all.

Called with keep_model set to TRUE, the trimming process is less complete. In particular internal models are simplified using butcher::butcher() and some additional minor reductions. This saves less memory but enables the use of loglikelihood.covlmc() for new data as well as the use of simulate.covlmc().

See also

Examples

pc <- powerconsumption[powerconsumption$week %in% 5:7, ]
dts <- cut(pc$active_power, breaks = c(0, quantile(pc$active_power, probs = c(0.5, 1))))
dts_cov <- data.frame(day_night = (pc$hour >= 7 & pc$hour <= 17))
m_cov <- covlmc(dts, dts_cov, min_size = 10, keep_data = TRUE)
print(object.size(m_cov), units = "Mb")
#> 26.9 Mb
t_m_cov_model <- trim(m_cov, keep_model = TRUE)
print(object.size(t_m_cov_model), units = "Mb")
#> 8.3 Mb
t_m_cov <- trim(m_cov)
print(object.size(t_m_cov), units = "Mb")
#> 0.1 Mb