tlars_cpp {tlars} | R Documentation |
Exposes the C++ class tlars_cpp to R
Description
Type 'tlars_cpp' in the console to see the constructors, variables, and methods of the class tlars_cpp.
Arguments
X |
Real valued predictor matrix. |
y |
Response vector. |
verbose |
Logical. If TRUE progress in computations is shown. |
intercept |
Logical. If TRUE an intercept is included. |
standardize |
Logical. If TRUE the predictors are standardized and the response is centered. |
num_dummies |
Number of dummies that are appended to the predictor matrix. |
type |
Type of used algorithm (currently possible choices: 'lar' or 'lasso'). |
lars_state |
Input list that was extracted from a previous tlars_cpp object using get_all(). |
T_stop |
Number of included dummies after which the random experiments (i.e., forward selection processes) are stopped. |
early_stop |
Logical. If TRUE, then the forward selection process is stopped after T_stop dummies have been included. Otherwise the entire solution path is computed. |
Value
No return value. Exposes the C++ class tlars_cpp to R.
Fields
Constructor:
new - Creates a new object of the class tlars_cpp.
Constructor:
new - Re-creates an object of the class tlars_cpp based on a list of class variables that is obtained via get_all().
Method:
execute_lars_step - Executes LARS steps until a stopping-condition is satisfied.
Method:
get_beta - Returns the estimate of the beta vector.
Method:
get_beta_path - Returns a a matrix with the estimates of the beta vectors at all steps.
Method:
get_num_active - Returns the number of active predictors.
Method:
get_num_active_dummies - Returns the number of dummy variables that have been included.
Method:
get_num_dummies - Returns the number of dummy predictors.
Method:
get_actions - Returns the indices of added/removed variables along the solution path.
Method:
get_df - Returns the degrees of freedom at each step which is given by number of active variables (+1 if intercept is true).
Method:
get_R2 - Returns the R^2 statistic at each step.
Method:
get_RSS - Returns the residual sum of squares at each step.
Method:
get_Cp - Returns the Cp-statistic at each step.
Method:
get_lambda - Returns the lambda-values (penalty parameters) at each step along the solution path.
Method:
get_entry - Returns the first entry/selection steps of the predictors along the solution path.
Method:
get_norm_X - Returns the L2-norm of the predictors.
Method:
get_mean_X - Returns the sample means of the predictors.
Method:
get_mean_y - Returns the sample mean of the response y.
Method:
get_all - Returns all class variables: This list can be used as an input to the constructor to re-create an object of class tlars_cpp.
Examples
data("Gauss_data")
X <- Gauss_data$X
y <- drop(Gauss_data$y)
p <- ncol(X)
n <- nrow(X)
dummies <- matrix(stats::rnorm(n * p), nrow = n, ncol = p)
XD <- cbind(X, dummies)
mod_tlars <- tlars_model(X = XD, y = y, num_dummies = ncol(dummies))
tlars(model = mod_tlars, T_stop = 3, early_stop = TRUE)
mod_tlars$get_beta()
# mod_tlars$get_beta_path()
# mod_tlars$get_num_active()
# mod_tlars$get_num_active_dummies()
# mod_tlars$get_num_dummies()
# mod_tlars$get_actions()
# mod_tlars$get_df()
# mod_tlars$get_R2()
# mod_tlars$get_RSS()
# mod_tlars$get_Cp()
# mod_tlars$get_lambda()
# mod_tlars$get_entry()
# mod_tlars$get_norm_X()
# mod_tlars$get_mean_X()
# mod_tlars$get_mean_y()
# mod_tlars$get_all()