calculate_error_term {RCTS} | R Documentation |
Calculates the error term Y - X*beta_est - LF - LgFg.
Description
Calculates the error term Y - X*beta_est - LF - LgFg.
Usage
calculate_error_term(
Y,
X,
beta_est,
g,
factor_group,
lambda_group,
comfactor,
lambda,
S,
k,
kg,
method_estimate_beta = "individual",
no_common_factorstructure = FALSE,
no_group_factorstructure = 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_group |
loadings of the estimated group specific factors |
comfactor |
estimated common factors |
lambda |
loadings of the 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 |
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". |
no_common_factorstructure |
if there is a common factorstructure being estimated |
no_group_factorstructure |
if there is a group factorstructure being estimated |
Value
NxT matrix
Examples
X <- X_dgp3
Y <- Y_dgp3
# Set estimations for group factors and its loadings, and group membership
# to the true value for this example.
lambda_group <- lambda_group_true_dgp3
factor_group <- factor_group_true_dgp3
g <- g_true_dgp3
set.seed(1)
beta_est <- matrix(rnorm(nrow(Y) * 4), ncol = nrow(Y)) #random values for beta
comfactor <- matrix(0, ncol = ncol(Y))
lambda <- matrix(0, ncol = nrow(Y))
calculate_error_term(Y, X, beta_est, g, factor_group, lambda_group, comfactor, lambda,
3, 0, c(3, 3, 3))