RCTS0.2.4 package

Clustering Time Series While Resisting Outliers

calculate_lambda_group

calculates factor loadings of groupfactors

adapt_pic_with_sigma2maxmodel

Adapts the object that contains PIC for all candidate C's and all subs...

adapt_X_estimating_less_variables

When running the algorithm with a different number of observable varia...

add_configuration

Adds the current configuration (number of groups and factors) to df_re...

add_metrics

Adds several metrics to df_results.

add_pic

Fills in df_pic: adds a row with the calculated PIC for the current co...

add_pic_parallel

Calculates the PIC for the current configuration.

beta_true_heterogroups

Helpfunction in create_true_beta() for the option beta_true_heterogene...

calculate_best_config

Function that returns for each candidate C the best number of groups a...

calculate_error_term

Calculates the error term Y - X*beta_est - LF - LgFg.

calculate_errors_virtual_groups

Helpfunction for update_g(). Calculates the errors for one of the poss...

calculate_FL_group_estimated

Returns the estimated groupfactorstructure.

calculate_FL_group_true

Calculate the true groupfactorstructure.

calculate_lambda

calculates factor loadings of common factors

calculate_PIC

Function to determine PIC (panel information criterium)

calculate_PIC_term1

Function to calculate the first term of PIC (panel information criteri...

calculate_sigma2

Calculates sum of squared errors, divided by NT

calculate_sigma2maxmodel

Calculates sigma2maxmodel

calculate_TN_factor

Helpfunction. Calculates part of the 4th term of the PIC.

calculate_VCsquared

Calculates VC², to determine the stability of the found number of grou...

calculate_virtual_factor_and_lambda_group

Helpfunction used in update_g()

calculate_W

Calculates W = Y - X*beta_est. It is used in the initialization step o...

calculate_XB_estimated

Calculates (the estimated value of) the matrix X*beta_est.

calculate_XB_true

Calculates the product of X*beta_true .

calculate_Z_common

Calculates Z = Y - X*beta_est - LgFg. It is used in the estimate of th...

calculate_Z_group

Calculates Z = Y - X*beta_est - LF. It is used to estimate the groupfa...

check_stopping_rules

Checks the rules for stopping the algorithm, based on its convergence ...

clustering_with_robust_distances

Function that puts individuals in a separate "class zero", when their ...

create_covMat_crosssectional_dependence

Function used in generating simulated data with non normal errors.

create_data_dgp2

Creates an instance of DGP 2, as defined in if(!exists(".Rdpack.curref...

create_true_beta

Creates beta_true, which contains the true values of beta (= the coeff...

define_C_candidates

Defines the candidate values for C.

define_configurations

Constructs dataframe where the rows contains all configurations that a...

define_kg_candidates

Defines the set of combinations of group specific factors.

define_number_subsets

Returns a vector with the indices of the subsets. Must start with zero...

define_object_for_initial_clustering_macropca

Defines the object that will be used to define a initial clustering.

define_rho_parameters

Determines parameters of rho-function.

determine_beta

Helpfunction in estimate_beta() for estimating beta_est.

determine_robust_lambda

Help-function for return_robust_lambdaobject().

do_we_estimate_common_factors

Helpfunction to shorten code: are common factors being estimated.

do_we_estimate_group_factors

Helpfunction to shorten code: are group factors being estimated.

estimate_algorithm

This function is a wrapper around the initialization and the estimatio...

estimate_beta

Estimates beta.

estimate_factor

Estimates common factor(s) F.

estimate_factor_group

Estimates group factors Fg.

evade_crashes_macropca

Solves a very specific issue with MacroPCA.

evade_floating_point_errors

Function to evade floating point errors.

fill_rc

Fills in the optimized number of common factors for each C.

fill_rcj

Fills in the optimized number of groups and group specific factors for...

final_estimations_filter_kg

Filters dataframe on the requested group specific factors configuratio...

generate_grouped_factorstructure

Generates the true groupfactorstructure, to use in simulations.

generate_Y

Generate panel data Y for simulations.

get_best_configuration

Finds the first stable interval after the first unstable point. It the...

get_convergence_speed

Defines the convergence speed.

get_final_estimation

Function that returns the final clustering, based on the estimated num...

grid_add_variables

Function which is used to have a dataframe (called "grid") with data (...

handle_macropca_errors

Helpfunction in robustpca().

handleNA

Function with as input a dataframe. (this will be "Y" or "to_divide") ...

handleNA_LG

Removes NA's in LG (in function calculate_virtual_factor_and_lambda_gr...

initialise_beta

Initialisation of estimation of beta (the coefficients with the observ...

initialise_clustering

Function that clusters time series in a dataframe with kmeans.

initialise_commonfactorstructure_macropca

Initialises the estimation of the common factors and their loadings.

initialise_df_pic

Initialises a dataframe which will contain the PIC for each configurat...

initialise_df_results

Initialises a dataframe that will contain an overview of metrics for e...

initialise_rc

Initialises rc.

initialise_rcj

Initialises rcj.

initialise_X

Creates X (the observable variables) to use in simulations.

iterate

Wrapper around estimate_beta(), update_g(), and estimating the factors...

kg_candidates_expand

Function that returns the set of combinations of groupfactors for whic...

LMROB

Wrapper around lmrob.

make_df_pic_parallel

Makes a dataframe with the PIC for each configuration and each candida...

make_df_results_parallel

Makes a dataframe with information on each configuration.

make_subsamples

Selects a subsample of the time series, and of the length of the time ...

matrixnorm

Function to calculate the norm of a matrix.

OF_vectorized_helpfunction3

Helpfunction in OF_vectorized3()

OF_vectorized3

Calculates objective function for the classical algorithm: used in ite...

parallel_algorithm

Wrapper of the loop over the subsets which in turn use the parallelise...

plot_VCsquared

Plots expression(VC^2) along with the corresponding number of groups (...

prepare_for_robpca

Helpfunction: prepares object to perform robust PCA on.

RCTS

RCTS

reassign_if_empty_groups

Randomly reassign individual(s) if there are empty groups. This can ha...

restructure_X_to_order_slowN_fastT

Restructures X (which is an 3D-array of dimensions (N,T,p) to a 2D-mat...

return_robust_lambdaobject

Calculates robust loadings

robustpca

Function that uses robust PCA and estimates robust factors and loading...

run_config

Wrapper around the non-parallel algorithm, to estimate beta, group mem...

scaling_X

Scaling of X.

solveFG

Helpfunction in update_g(), to calculate solve(FG x t(FG)) x FG

tabulate_potential_C

Shows the configurations for potential C's of the first stable interva...

update_g

Function that estimates group membership.

calculate_lgfg

Calculates the group factor structure: the matrix product of the group...

calculate_obj_for_g

Calculates objective function for individual i and group k in order to...

Robust Clustering of Time Series (RCTS) has the functionality to cluster time series using both the classical and the robust interactive fixed effects framework. The classical framework is developed in Ando & Bai (2017) <doi:10.1080/01621459.2016.1195743>. The implementation within this package excludes the SCAD-penalty on the estimations of beta. This robust framework is developed in Boudt & Heyndels (2022) <doi:10.1016/j.ecosta.2022.01.002> and is made robust against different kinds of outliers. The algorithm iteratively updates beta (the coefficients of the observable variables), group membership, and the latent factors (which can be common and/or group-specific) along with their loadings. The number of groups and factors can be estimated if they are unknown.

  • Maintainer: Ewoud Heyndels
  • License: GPL (>= 2)
  • Last published: 2023-05-18