estimate_beta {RCTS}R Documentation

Estimates beta.

Description

Update step of algorithm to obtain new estimation for beta. Note that we call it beta_est because beta() exists in base R.

Usage

estimate_beta(
  Y,
  X,
  beta_est,
  g,
  lambda_group,
  factor_group,
  lambda,
  comfactor,
  method_estimate_beta = "individual",
  S,
  k,
  kg,
  vars_est,
  robust,
  num_factors_may_vary = TRUE,
  optimize_kappa = FALSE,
  nosetting = 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

lambda_group

loadings of the estimated group specific factors

factor_group

estimated group specific factors

lambda

loadings of the estimated common factors

comfactor

estimated common factors

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

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

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

num_factors_may_vary

whether or not the number of groupfactors is constant over all groups or not

optimize_kappa

indicates if kappa has to be optimized or not (only relevant for the classical algorithm)

nosetting

option to remove the recommended setting in lmrob(). It is much faster. Defaults to FALSE.

Value

list: 1st element contains matrix (N columns: 1 for each time series of the panel data) with estimated beta_est's. If vars_est is set to 0, the list contains NA.

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 <- g_true_dgp3
# There are no common factors to be estimated  -> but needs placeholder
lambda <- matrix(0, nrow = 1, ncol = 300)
comfactor <- matrix(0, nrow = 1, ncol = 30)
#
# Choose how coefficients of the observable variables are estimated
method_estimate_beta <- "individual"
method_estimate_factors <- "macro"
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]]


[Package RCTS version 0.2.4 Index]