fit_blockcpd | R Documentation |
Fits a blockcpd model to find the best segmentation of the data into blocks. Variables in each block have the same distribution and parameter, and consecutive blocks have different parameters.
fit_blockcpd( data_matrix, method = "hierseg", family = "bernoulli", lambda = 1, pen_func = bic_loss, min_block_size = 1L, max_blocks = NULL, bootstrap = FALSE, bootstrap_samples = 100L, bootstrap_progress = FALSE, skip_input_check = FALSE )
data_matrix |
Data frame or matrix containing the data set to be segmented. There is no verification if the entries correspond to the model specified by the "family" argument, such as entries different than 0, 1 or NA for the bernoulli family. |
method |
The method that will be used to fit the model. The current implemented models are:
|
family |
The name of the family to detect changes in parameters. Should be passed as a string. The families currently implemented are:
|
lambda |
The penalization constant. Must be a unique non-negative numeric value. |
pen_func |
Regularization function used for fitting, with default as the BIC. For user specified functions, check the template in the regularization regularization.rd file. |
min_block_size |
Minimum block size allowed. Default is 1, and the value must be smaller or equal to ncol. |
max_blocks |
An integer greater than 0 that specify the maximum number of blocks fitted by the algorithm. It is only used if dynseg is specified in the "method" argument. |
bootstrap |
A flag to decide if bootstrap computations for the estimation of the probability of each index being detected as a change point. It also provides a sample of all the metrics implemented computed with respect to the final change point set estimated. |
bootstrap_samples |
Number of bootstrap samples. |
bootstrap_progress |
Flag for bootstrap progress printing. |
skip_input_check |
Flag indicating if input checking should be skipped. |
The function returns a S3 object of the type blockcpd.
"changepoints" a list containing the set of estimated change points;
"parameters" a list containing the estimated parameters for each block. In the case of multiple parameters, it provides a list of lists, where each sub list refers to the parameter that names the list;
"loss" the final loss evaluated on the entire data set for the returned model;
"neg_loglike" The negative log likelihood of the model;
"ncp" number of change points estimated;
"metadata" Arguments passed to fit the model;
"bootstrap_info" if bootstrap argument is true, this contains a list of the metrics for each bootstrap sample, and contains the estimated probability of each index being detected as a change point;
fit_blockcpd(c(0, 1, 2, 10, 11), family = "normal", lambda = 1) # single series fit_blockcpd(matrix(c(0, 1, 0, 0, 0, 0, 1, 1), nrow = 2)) # 2 binary series
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.