update_g {RCTS} | R Documentation |
Function that estimates group membership.
Description
Function that estimates group membership.
Usage
update_g(
Y,
X,
beta_est,
g,
factor_group,
lambda,
comfactor,
S,
k,
kg,
vars_est,
robust,
method_estimate_factors,
method_estimate_beta,
verbose = FALSE
)
Arguments
Y |
Y: NxT dataframe with the panel data of interest |
X |
X: NxTxp array containing the observable variables |
beta_est |
estimated values of beta |
g |
Vector with estimated group membership for all individuals |
factor_group |
estimated group specific factors |
lambda |
loadings of the estimated common factors |
comfactor |
estimated common factors |
S |
number of estimated groups |
k |
number of common factors to be estimated |
kg |
number of group specific factors to be estimated |
vars_est |
number of variables that will be included in the algorithm and have their coefficient estimated. This is usually equal to the number of observable variables. |
robust |
robust or classical estimation of group membership |
method_estimate_factors |
defines method of robust estimaton of the factors: "macro", "pertmm" or "cz" |
method_estimate_beta |
defines how beta is estimated. Default case is an estimated beta for each individual. Default value is "individual." Possible values are "homogeneous", "group" or "individual". |
verbose |
when TRUE, it prints messages |
Value
Returns a list. The first element contains a vector with the estimated group membership for all time series. The second element contains the values which were used to determine the group membership. The third element is only relevant if method_estimate_factors is set to "cz" (non-default) and contains the group membership before moving some of the time series to class zero.
Examples
X <- X_dgp3
Y <- Y_dgp3
# Set estimations for group factors and its loadings, and group membership to the true value
lambda_group <- lambda_group_true_dgp3
factor_group <- factor_group_true_dgp3
g_true <- g_true_dgp3 # true values of group membership
g <- g_true # estimated values of group membership; set in this example to be equal to true values
# There are no common factors to be estimated -> use placeholder with values set to zero
lambda <- matrix(0, nrow = 1, ncol = 300)
comfactor <- matrix(0, nrow = 1, ncol = 30)
# Choose how coefficients of the observable are estimated
beta_est <- estimate_beta(
Y, X, NA, g, lambda_group, factor_group,
lambda, comfactor,
S = 3, k = 0, kg = c(3, 3, 3),
vars_est = 3, robust = TRUE
)[[1]]
g_new <- update_g(
Y, X, beta_est, g,
factor_group, lambda, comfactor,
S = 3,
k = 0,
kg = c(3, 3, 3),
vars_est = 3,
robust = TRUE,
"macro", "individual"
)[[1]]