calculate_lambda_group {RCTS}R Documentation

calculates factor loadings of groupfactors

Description

returns object which includes group and id of the individuals

Usage

calculate_lambda_group(
  Y,
  X,
  beta_est,
  factor_group,
  g,
  lambda,
  comfactor,
  S,
  k,
  kg,
  robust,
  method_estimate_beta = "individual",
  method_estimate_factors = "macro",
  verbose = FALSE,
  initialise = 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

factor_group

estimated group specific factors

g

Vector with estimated group membership for all individuals

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

robust

TRUE or FALSE: defines using the classical or robust algorithm to estimate beta

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".

method_estimate_factors

defines method of robust estimaton of the factors: "macro", "pertmm" or "cz"

verbose

when TRUE, it prints messages

initialise

indicator of being in the initialisation phase

Value

Returns a data.frame with a row for each time series. The first number of columns contain the individual loadings to the group specific factors. Furthermore "group" (group membership) and id (the order in which the time series appear in Y) are added.

Examples

#' #example with data generated with DGP 2
data <- create_data_dgp2(30, 10)
Y <- data[[1]]
X <- data[[2]]
g <- data[[3]] #true group membership
set.seed(1)
beta_est <- matrix(rnorm(4 * nrow(Y)), nrow = 4)
factor_group <- data[[5]] #true values of group specific factors
comfactor <- matrix(0, nrow = 1, ncol = ncol(Y))
lambda <- matrix(0, nrow = 1, ncol = nrow(Y))
calculate_lambda_group(Y, X, beta_est, factor_group, g, lambda, comfactor,
3, 0, c(3, 3, 3), TRUE)

[Package RCTS version 0.2.4 Index]