Skip to content

Commit

Permalink
[CRAN] Prepare release v1.0.0 to CRAN (#7)
Browse files Browse the repository at this point in the history
* CHG: refine readme; update the description; add licence file; update the ignoring tag

* CHG: refine README content

* CHG: refine the r code by enhancing readbility, reformatting, and reducing redundant arguments

* CHG: refine the rcpp code and description

* CHG: add p parameter as mandatory; update the test cases and fix example code

* CHG: refine wordings; update the manunal

* FIX: correct typos

* FIX: correct the bugs from CRAN result

* CHG: enhance the example code

* FIX: correct the codecov url

* CHG: refine code based on the review comments

* CHG: refine the par issue

* CHG: refine example code by the CRAN review

* FIX: regenerate the manual

* Update README.md

* CHG: update the release note
  • Loading branch information
egpivo authored Jan 16, 2024
1 parent d719b06 commit 2006e4d
Show file tree
Hide file tree
Showing 21 changed files with 912 additions and 549 deletions.
4 changes: 3 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
^\.github$
^codecov\.yml$
^.*\.gcno$
^NEWS$
^NEWS$
LICENSE
\.github
25 changes: 15 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: QuantRegGLasso
Title: Adaptively Weighted Group Lasso for Semiparametic Quantile Rgression Models
Version: 0.5.0
Title: Adaptively Weighted Group Lasso for Semiparametric Quantile Regression Models
Version: 1.0.0
Authors@R: c(person(
given = "Wen-Ting",
family = "Wang",
Expand All @@ -12,23 +12,29 @@ Authors@R: c(person(
given = "Wei-Ying",
family = "Wu",
email = "wuweiying1011@gmail.com",
role = "aut"
),
role = c("aut")
),
person(
given = "Toshio",
family = "Honda",
email="t.honda@r.hit-u.ac.jp",
rol = c("aut")),
email = "t.honda@r.hit-u.ac.jp",
role = c("aut")
),
person(
given = "Ching-Kang",
family = "Ing",
email="cking@stat.nthu.edu.tw",
rol = c("aut"),
role = c("aut"),
comment = c(ORCID = "0000-0003-1362-8246")
)
)
Description: Address adaptively weighted group Lasso procedures of quantile regression problems. It excels in simultaneous variable selection and structure identification for varying coefficient quantile regression models, as well as additive quantile regression models featuring ultra-high dimensional covariates. (Toshio Honda, Ching-Kang Ing, Wei-Ying Wu, 2019,. <DOI: 10.3150/18-BEJ1091>).
License: GPL-3
Description: Implements an adaptively weighted group Lasso procedure for simultaneous variable selection and structure identification in varying
coefficient quantile regression models and additive quantile regression models with ultra-high dimensional covariates. The methodology, grounded
in a strong sparsity condition, establishes selection consistency under certain weight conditions. To address the challenge of tuning parameter
selection in practice, a BIC-type criterion named high-dimensional information criterion (HDIC) is proposed. The Lasso procedure, guided by
HDIC-determined tuning parameters, maintains selection consistency. Theoretical findings are strongly supported by simulation studies.
(Toshio Honda, Ching-Kang Ing, Wei-Ying Wu, 2019, <DOI:10.3150/18-BEJ1091>).
License: GPL (>= 2)
LazyData: true
ByteCompile: true
BugReports: https://github.com/egpivo/QuantRegGLasso/issues
Expand All @@ -42,7 +48,6 @@ Suggests:
rmarkdown,
testthat (>= 2.1.0)
SystemRequirements: GNU make
VignetteBuilder: knitr
Encoding: UTF-8
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Expand Down
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## QuantRegGLasso 1.0.0 (Release Date: 2024-01-17)
### Overview
In this release, we have deployed the package to CRAN following its standard procedures. The main features of this release include:

- `qrglasso`: This function allows for model quantile regression by adaptively weighted group Lasso.
- `predict`: Generate estimations.
- `plot.qrglasso`: Investigate BIC performance.
- `plot.qrglasso.predict`: Visualize estimations.

- `orthogonize_bspline`: Orthogonalize B-splines using the built-in function `splines::bs`.
---


## QuantRegGLasso 0.5.0 (Release Date: 2024-01-11)
### Overview
- Added a `plot.qrglasso` function for displaying BIC w.r.t. hyperparameters via `qrglasso` object.
Expand Down
51 changes: 27 additions & 24 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Internal function: Quantile regression with adaptively group lasso with the input omega
#' @title Internal function: Quantile Regression with Adaptively Group Lasso with `Omega`
#' @keywords internal
#'
#' @param Y data matrix (n x 1)
#' @param W B-splines with covariates matrix (n x pL)
#' @param omega Weights for group lasso
#' @param lambda A sequence of tuning parameters
#' @param tau A quantile of interest
#' @param qn A bound parameter for HDIC
#' @param zeta A step parameter
#' @param zetaincre An increment of each step
#' @param maxit The maximum number of iterations
#' @param tol A tolerance rate
#' @return A list of selected parameters
#' @description Internal function: Quantile regression with adaptively group Lasso with `Omega`.
#' @param Y Data matrix (\eqn{n \times 1}).
#' @param W B-splines with covariates matrix with \eqn{p \times L} columns and \eqn{n} rows.
#' @param omega Weights for group lasso.
#' @param lambda A sequence of tuning parameters.
#' @param tau A quantile of interest.
#' @param qn A bound parameter for HDIC.
#' @param zeta A step parameter.
#' @param zetaincre An increment of each step.
#' @param maxit The maximum number of iterations.
#' @param tol A tolerance rate.
#' @return A list of selected parameters.
awgl_omega <- function(Y, W, omega, lambda, tau, qn, zeta, zetaincre, maxit, tol) {
.Call(`_QuantRegGLasso_awgl_omega`, Y, W, omega, lambda, tau, qn, zeta, zetaincre, maxit, tol)
}

#' Internal function: Quantile regression with adaptively group lasso without input Omega
#' @title Internal function: Quantile Regression with Adaptively Group Lasso without `Omega`
#' @keywords internal
#'
#' @param Y data matrix (n x 1)
#' @param W B-splines with covariates matrix (n x pL)
#' @param lambda A sequence of tuning parameters
#' @param tau A quantile of interest
#' @param L The number of groups
#' @param qn A bound parameter for HDIC
#' @param zeta A step parameter
#' @param zetaincre An increment of each step
#' @param maxit The maximum number of iterations
#' @param tol A tolerance rate
#' @return A list of selected parameters
#' @description Internal function: Quantile regression with adaptively group Lasso without `Omega`.
#' @param Y Data matrix (\eqn{n \times 1}).
#' @param W B-splines with covariates matrix with \eqn{p \times L} columns and \eqn{n} rows.
#' @param lambda A sequence of tuning parameters.
#' @param tau A quantile of interest.
#' @param L The number of groups.
#' @param qn A bound parameter for HDIC.
#' @param zeta A step parameter.
#' @param zetaincre An increment of each step.
#' @param maxit The maximum number of iterations.
#' @param tol A tolerance rate.
#' @return A list of selected parameters.
awgl <- function(Y, W, lambda, tau, L, qn, zeta, zetaincre, maxit, tol) {
.Call(`_QuantRegGLasso_awgl`, Y, W, lambda, tau, L, qn, zeta, zetaincre, maxit, tol)
}
Expand Down
88 changes: 55 additions & 33 deletions R/helper.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#' Orthogonalized B-splines
#' @title Orthogonalized B-splines
#' @description Generate a set of orthogonalized B-splines using the Gram-Schmidt algorithm applied to the built-in function `splines::bs()`.
#'
#' @param knots Array. The knots that define the spline.
#' @param boundary_knots Array. The breakpoints that define the spline.
#' @param degree Integer. The degree of the piecewise polynomial.
#' @param predictors Array. The predictor variables with size p.
#' @param is_approx Boolean. The default is `FALSE`.
#' @return A list containing:
#' \item{bsplines}{Matrix of orthogonalized B-splines with dimension (p, length(knots) + degree + 1)}
#' \item{z}{Predictors used in generation}
#' \item{\code{bsplines}}{Matrix of orthogonalized B-splines with dimensions \eqn{(p, \text{length}(knots) + \text{degree} + 1)}}
#' \item{\code{z}}{Predictors used in generation}
#' @export
#' @examples
#' # Example: Generate and plot the first 5 orthogonalized B-splines
#' p <- 30
#' total_knots <- 10
#' degree <- 3
Expand All @@ -17,14 +20,15 @@
#' knots <- x[2:(total_knots - 1)]
#' predictors <- runif(p, min = 0, max = 1)
#' bsplines <- orthogonize_bspline(knots, boundaries, degree, predictors)
#'
#' # Plot the first 5 B-splines
#' index <- order(bsplines$z)
#' original_par <- par(no.readonly = TRUE)
#' par(mfrow = c(1, 5))
#' for (i in 1:5)
#' plot(bsplines$z[index], bsplines$bsplines[index, i], main = i, type = "l")
#' par(original_par)
#'
#' @export
orthogonize_bspline <- function(
knots, boundary_knots, degree, predictors = NULL, is_approx = FALSE
) {
Expand Down Expand Up @@ -83,50 +87,58 @@ orthogonize_bspline <- function(
))
}


#' Internal function: Validate new locations for a qrglasso_object object
#' @title Internal Function: Validate Parameters for Prediction with a `qrglasso` Object
#'
#' @description Internal function to validate parameters for predicting with a `qrglasso` class object.
#'
#' @keywords internal
#' @param qrglasso_object An `qrglasso` class object.
#' @param metric_type Character. A metric type for gamma selection. e.g., `BIC`, `BIC-log`. Default is `BIC`.
#' @param top_k Integer. A matrix of the top K estimated functions.
#'
#' @param qrglasso_object A `qrglasso` class object.
#' @param metric_type Character. Metric type for gamma selection, e.g., `BIC`, `BIC-log`. Default is `BIC`.
#' @param top_k Integer. Top K estimated functions.
#' @param degree Integer. Degree of the piecewise polynomial.
#' @param boundaries Array. Two boundary points.
#'
#' @return `NULL`.
#'
check_predict_parameters <- function(qrglasso_object, metric_type, top_k, degree, boundaries) {
if (!inherits(qrglasso_object, "qrglasso")) {
stop("Invalid object! Please enter a `qrglasso` object")
stop("Invalid object! Please enter a `qrglasso` object.")
}
if (!(metric_type %in% c("BIC", "BIC-log"))) {
stop("Only accept types: `BIC` and `BIC-log`")
stop("Only accept types: `BIC` and `BIC-log`.")
}
if (top_k <= 0) {
stop("Please enter a positive top k")
stop("Please enter a positive top k.")
}
if (degree <= 0) {
stop("Please enter a positive degree")
stop("Please enter a positive degree.")
}
if (length(boundaries) != 2) {
stop("Please enter a size 2 boundaries.")
}
if (boundaries[1] >= boundaries[2]) {
stop("Please input valid boundaries consisting of two elements in ascending order.")
}
total_knots = qrglasso_object$L - degree + 1
total_knots <- qrglasso_object$L - degree + 1
if (total_knots <= 0) {
stop("Please enter a smaller degree")
stop("Please enter a smaller degree.")
}
}

#' Internal function: Plot sequentially
#' @title Internal Function: Plot Sequentially
#'
#' @description Internal function to plot ggplot2 objects sequentially.
#'
#' @keywords internal
#' @param objs Valid ggplot2 objects
#' @return `NULL`
#'
#'
#' @param objs List. Valid ggplot2 objects to be plotted sequentially.
#'
#' @return `NULL`.
#'
plot_sequentially <- function(objs) {
originalPar <- par(no.readonly = TRUE)
on.exit(par(originalPar))
original_par <- par(no.readonly = TRUE)
on.exit(par(original_par))
par(ask = TRUE)
suppressWarnings({
for (obj in objs) {
Expand All @@ -136,43 +148,53 @@ plot_sequentially <- function(objs) {
par(ask = FALSE)
}

#' Internal function: Plot Coefficient Function
#' @title Internal Function: Plot Coefficient Function
#'
#' @description Internal function to plot coefficient functions using ggplot2.
#'
#' @keywords internal
#' @param data A dataframe contains columns ``z``, ``coefficient``
#' @param variate A character represent the title
#' @return A ggplot object
#'
#' @param data Dataframe. A dataframe containing columns ``z``, ``coefficient``.
#' @param variate Character. A character representing the title.
#'
#' @return A ggplot object.
#'
plot_coefficient_function <- function(data, variate) {
default_theme <- theme_classic() +
theme(
text = element_text(size = 24),
plot.title = element_text(hjust = 0.5)
)
result <- ggplot(data, aes(x = z, y = coefficient)) +
geom_point(col="#4634eb") +
geom_point(col = "#4634eb") +
ggtitle(variate) +
default_theme
return(result)
}


#' Internal function: Plot BIC Results w.r.t. lambda
#' @title Internal Function: Plot BIC Results w.r.t. lambda
#'
#' @description Internal function to plot BIC results with respect to lambda using ggplot2.
#'
#' @keywords internal
#' @param data A dataframe contains columns ``lambda``, ``bic``
#' @param variate A character represent the title
#' @return A ggplot object
#'
#' @param data Dataframe. A dataframe containing columns ``lambda``, ``bic``.
#' @param variate Character. A character representing the title.
#'
#' @return A ggplot object.
#'
plot_bic_result <- function(data, variate) {
default_theme <- theme_classic() +
theme(
text = element_text(size = 24),
plot.title = element_text(hjust = 0.5)
)
result <- ggplot(data, aes(x = lambda, y = bic)) +
geom_point(col="#4634eb") +
geom_point(col = "#4634eb") +
geom_line() +
ggtitle(variate) +
xlab(expression(lambda)) +
ylab("BIC") +
default_theme
return(result)
}

Loading

0 comments on commit 2006e4d

Please sign in to comment.