Skip to content

Commit

Permalink
Merge pull request #21 from ocbe-uio/issue-5
Browse files Browse the repository at this point in the history
Fixed documentation for C++ function (#5)
  • Loading branch information
Theo-qua authored Jan 12, 2024
2 parents ce752c7 + 68ce41d commit 582223b
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 40 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ S3method(plot,cv_MADMMplasso)
S3method(predict,MADMMplasso)
export(MADMMplasso)
export(admm_MADMMplasso)
export(admm_MADMMplasso_cpp)
export(compute_pliable)
export(cv_MADMMplasso)
export(generate_my_w)
Expand Down
32 changes: 32 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Fit the ADMM part of model for a given lambda vale
#' @param X n by p matrix of predictors
#' @param Z n by nz matrix of modifying variables. The elements of z
#' may represent quantitative or categorical variables, or a mixture of the two.
#' Categorical varables should be coded by 0-1 dummy variables: for a k-level
#' variable, one can use either k or k-1 dummy variables.
#' @param beta0 a vector of length ncol(y) of estimated beta_0 coefficients
#' @param theta0 matrix of the initial theta_0 coefficients ncol(Z) by ncol(y)
#' @param beta a matrix of the initial beta coefficients ncol(X) by ncol(y)
#' @param beta_hat a matrix of the initial beta and theta coefficients (ncol(X)+ncol(X) by ncol(Z)) by ncol(y)
#' @param theta an array of initial theta coefficients ncol(X) by ncol(Z) by ncol(y)
#' @param rho1 the Lagrange variable for the ADMM which is usually included as rho in the MADMMplasso call.
#' @param max_it maximum number of iterations in loop for one lambda during the ADMM optimization. This is usually included in the MADMMplasso call
#' @param W_hat N by (p+(p by nz)) of the main and interaction predictors. This generated internally when MADMMplasso is called or by using the function generate_my_w.
#' @param XtY a matrix formed by multiplying the transpose of X by y.
#' @param y N by D matrix of responses. The X and Z variables are centered in the function. We recommend that X and Z also be standardized before the call
#' @param N nrow(X)
#' @param e_abs absolute error for the admm. This is included int the call of MADMMplasso.
#' @param e_rel relative error for the admm. This is included int the call of MADMMplasso.
#' @param alpha mixing parameter, usually obtained from the MADMMplasso call. When the goal is to include more interactions, alpha should be very small and vice versa.
#' @param lambda a vector lambda_3 values for the admm call with length ncol(y). This is usually calculated in the MADMMplasso call. In our current setting, we use the same the lambda_3 value for all responses.
#' @param alph an overrelaxation parameter in \[1, 1.8\], usually obtained from the MADMMplasso call.
#' @param svd_w singular value decomposition of W
#' @param tree The results from the hierarchical clustering of the response matrix.
#' The easy way to obtain this is by using the function (tree_parms) which gives a default clustering.
#' However, user decide on a specific structure and then input a tree that follows such structure.
#' @param my_print Should information form each ADMM iteration be printed along the way? Default TRUE. This prints the dual and primal residuals
#' @param invmat A list of length ncol(y), each containing the C_d part of equation 32 in the paper
#' @param gg penalty terms for the tree structure for lambda_1 and lambda_2 for the admm call.
#' @return predicted values for the ADMM part
#' @description TODO: add description
#' @export
admm_MADMMplasso_cpp <- function(beta0, theta0, beta, beta_hat, theta, rho1, X, Z, max_it, W_hat, XtY, y, N, e_abs, e_rel, alpha, lambda, alph, svd_w, tree, invmat, gg, my_print = TRUE) {
.Call(`_MADMMplasso_admm_MADMMplasso_cpp`, beta0, theta0, beta, beta_hat, theta, rho1, X, Z, max_it, W_hat, XtY, y, N, e_abs, e_rel, alpha, lambda, alph, svd_w, tree, invmat, gg, my_print)
}
Expand Down
90 changes: 90 additions & 0 deletions man/admm_MADMMplasso_cpp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 32 additions & 40 deletions src/admm_MADMMplasso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,38 @@
#include "misc.h"

// [[Rcpp::depends(RcppArmadillo)]]
// #' Fit the ADMM part of model for a given lambda vale
// #' @param X n by p matrix of predictors
// #' @param Z n by nz matrix of modifying variables. The elements of z
// #' may represent quantitative or categorical variables, or a mixture of the two.
// #' Categorical varables should be coded by 0-1 dummy variables: for a k-level
// #' variable, one can use either k or k-1 dummy variables.
// #' @param beta0 TODO: fill paramater description
// #' @param theta0 TODO: fill paramater description
// #' @param beta TODO: fill paramater description
// #' @param beta_hat TODO: fill paramater description
// #' @param theta TODO: fill paramater description
// #' @param rho1 TODO: fill paramater description
// #' @param max_it TODO: fill paramater description
// #' @param W_hat TODO: fill paramater description
// #' @param XtY TODO: fill paramater description
// #' @param y TODO: fill paramater description
// #' @param N TODO: fill paramater description
// #' @param p TODO: fill paramater description
// #' @param K TODO: fill paramater description
// #' @param e.abs TODO: fill paramater description
// #' @param e.rel TODO: fill paramater description
// #' @param alpha TODO: fill paramater description
// #' @param lambda TODO: fill paramater description
// #' @param alph TODO: fill paramater description
// #' @param svd.w TODO: fill paramater description
// #' @param tree TODO: fill paramater description
// #' @param my_print TODO: fill paramater description
// #' @param invmat TODO: fill paramater description
// #' @param V TODO: fill paramater description
// #' @param Q TODO: fill paramater description
// #' @param E TODO: fill paramater description
// #' @param EE TODO: fill paramater description
// #' @param O TODO: fill paramater description
// #' @param P TODO: fill paramater description
// #' @param H TODO: fill paramater description
// #' @param HH TODO: fill paramater description
// #' @param gg TODO: fill paramater description
// #' @return predicted values for the ADMM part
// #' @description TODO: add description
// #' @export
//' Fit the ADMM part of model for a given lambda vale
//' @param X n by p matrix of predictors
//' @param Z n by nz matrix of modifying variables. The elements of z
//' may represent quantitative or categorical variables, or a mixture of the two.
//' Categorical varables should be coded by 0-1 dummy variables: for a k-level
//' variable, one can use either k or k-1 dummy variables.
//' @param beta0 a vector of length ncol(y) of estimated beta_0 coefficients
//' @param theta0 matrix of the initial theta_0 coefficients ncol(Z) by ncol(y)
//' @param beta a matrix of the initial beta coefficients ncol(X) by ncol(y)
//' @param beta_hat a matrix of the initial beta and theta coefficients (ncol(X)+ncol(X) by ncol(Z)) by ncol(y)
//' @param theta an array of initial theta coefficients ncol(X) by ncol(Z) by ncol(y)
//' @param rho1 the Lagrange variable for the ADMM which is usually included as rho in the MADMMplasso call.
//' @param max_it maximum number of iterations in loop for one lambda during the ADMM optimization. This is usually included in the MADMMplasso call
//' @param W_hat N by (p+(p by nz)) of the main and interaction predictors. This generated internally when MADMMplasso is called or by using the function generate_my_w.
//' @param XtY a matrix formed by multiplying the transpose of X by y.
//' @param y N by D matrix of responses. The X and Z variables are centered in the function. We recommend that X and Z also be standardized before the call
//' @param N nrow(X)
//' @param e_abs absolute error for the admm. This is included int the call of MADMMplasso.
//' @param e_rel relative error for the admm. This is included int the call of MADMMplasso.
//' @param alpha mixing parameter, usually obtained from the MADMMplasso call. When the goal is to include more interactions, alpha should be very small and vice versa.
//' @param lambda a vector lambda_3 values for the admm call with length ncol(y). This is usually calculated in the MADMMplasso call. In our current setting, we use the same the lambda_3 value for all responses.
//' @param alph an overrelaxation parameter in \[1, 1.8\], usually obtained from the MADMMplasso call.
//' @param svd_w singular value decomposition of W
//' @param tree The results from the hierarchical clustering of the response matrix.
//' The easy way to obtain this is by using the function (tree_parms) which gives a default clustering.
//' However, user decide on a specific structure and then input a tree that follows such structure.
//' @param my_print Should information form each ADMM iteration be printed along the way? Default TRUE. This prints the dual and primal residuals
//' @param invmat A list of length ncol(y), each containing the C_d part of equation 32 in the paper
//' @param gg penalty terms for the tree structure for lambda_1 and lambda_2 for the admm call.
//' @return predicted values for the ADMM part
//' @description TODO: add description
//' @export
// [[Rcpp::export]]
Rcpp::List admm_MADMMplasso_cpp(
const arma::vec beta0,
Expand Down

0 comments on commit 582223b

Please sign in to comment.