Skip to contents

This function prunes a vlmc with covariates. This model must have been estimated with keep_data=TRUE to enable the pruning.

Usage

# S3 method for covlmc
prune(vlmc, alpha = 0.05, cutoff = NULL, ...)

Arguments

vlmc

a fitted VLMC model with covariates.

alpha

number in (0,1) (default: 0.05) cutoff value in quantile scale for pruning.

cutoff

not supported by the vlmc with covariates.

...

additional arguments for the prune function.

Value

a pruned covlmc.

Details

Post pruning a VLMC with covariates is not as straightforward as the same procedure applied to vlmc() (see cutoff.vlmc() and prune.vlmc()). For efficiency reasons, covlmc() estimates only the logistic models that are considered useful for a given set construction parameters. With a more aggressive pruning threshold, some contexts become leaves of the context tree and new logistic models must be estimated. Thus the pruning opportunities given by cutoff.covlmc() are only a subset of interesting cut offs for a given covlmc.

Nevertheless, covlmc share with vlmc() the principle that post pruning a covlmc should give the same model as buidling directly the covlmc, provided that the post pruning alpha is smaller than the alpha used to build the initial model.

Examples

pc <- powerconsumption[powerconsumption$week == 5, ]
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 = 5, keep_data = TRUE)
draw(m_cov)
#> *
#> +-- (0,1.34]
#> |   +-- (0,1.34]
#> |   |   +-- (0,1.34] (0.02329 [ -2.813 2.178 -4.449 2.418 ])
#> |   |   '-- (1.34,7.54] (0.01834 [ -19.57 18.39 ])
#> |   '-- (1.34,7.54] (0.6763 [ -1.856 ])
#> '-- (1.34,7.54] (0.8175 [ 2.535 ])
m_cov_cuts <- cutoff(m_cov)
p_cov <- prune(m_cov, m_cov_cuts[1])
draw(p_cov)
#> *
#> +-- (0,1.34]
#> |   +-- (0,1.34] (0.02001 [ -2.759 2.785 -2.525 ])
#> |   '-- (1.34,7.54] (0.6763 [ -1.856 ])
#> '-- (1.34,7.54] (0.8175 [ 2.535 ])