Skip to content

Commit

Permalink
CRAN compabilities changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyChristidis committed Sep 1, 2019
1 parent d953e7a commit efb2ff6
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 26 deletions.
12 changes: 9 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ Package: RPEGLMEN
Type: Package
Title: Efficient Implementation of glmnet using Rcpp and RcppEigen
Version: 0.1.0
Author: Anthony Christidis, Xin Chen, Daniel Hanson
Date: 2019-08-30
Author: Anthony Christidis <anthony.christidis@stat.ubc.ca>,
Xin Chen <chenx26@uw.edu>,
Daniel Hanson <hansondj@uw.edu>
Maintainer: Anthony Christidis <anthony.christidis@stat.ubc.ca>
Description: Implements the FISTA algorithm to fit a Gamma distribution
with an elastic net penalty as described in Chen, Arakvin and
Martin (2018) <https://arxiv.org/abs/1804.07780>. An implementation
for the case of the exponential distribution is also available, with
details available in Chen and Martin (2018)
<https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3085672>.
License: GPL
License: GPL (>= 2)
Encoding: UTF-8
LazyData: true
Imports: Rcpp (>= 0.12.11)
Imports: Rcpp (>= 1.0.2), RcppEigen (>= 0.3.3.5.0)
LinkingTo: Rcpp, RcppEigen
RoxygenNote: 6.1.1
Suggests:
testthat
NeedsCompilation: yes
Biarch: true
SystemRequirements: C++11
9 changes: 6 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp, evalCpp)
# Generated by roxygen2: do not edit by hand

export(fit.glmGammaNet)
export(glmnet_exp)
import(stats)
import(utils)
useDynLib(RPEGLMEN)
importFrom(Rcpp,evalCpp)
useDynLib(RPEGLMEN, .registration = TRUE)
5 changes: 1 addition & 4 deletions R/FISTA.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
## This is the R implementation of FISTA, based on
## https://people.rennes.inria.fr/Cedric.Herzet/Cedric.Herzet/Sparse_Seminar/Entrees/2012/11/12_A_Fast_Iterative_Shrinkage-Thresholding_Algorithmfor_Linear_Inverse_Problems_(A._Beck,_M._Teboulle)_files/Breck_2009.pdf
## Author: Xin Chen
## 03/21/2018
## This is the R implementation of FISTA
FISTA = function(x0, f, g, f_grad, g_prox, ABSTOL = 1e-8, maxiter = 1000){
lambda = 1
beta = 0.5
Expand Down
14 changes: 7 additions & 7 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

scalarMultiplication <- function(c, M) {
.Call('_RPEGLMEN_scalarMultiplication', PACKAGE = 'RPEGLMEN', c, M)
.Call(`_RPEGLMEN_scalarMultiplication`, c, M)
}

addReals <- function(x, y) {
.Call('_RPEGLMEN_addReals', PACKAGE = 'RPEGLMEN', x, y)
.Call(`_RPEGLMEN_addReals`, x, y)
}

fitGlmFixed <- function(predictor_matrix, response_vector, alpha = 1, num_lambda = 100L, glm_type = 1L, max_iter = 100L, abs_tol = 1.0e-4, rel_tol = 1.0e-2, normalize_grad = FALSE, k_fold = 5L) {
.Call('_RPEGLMEN_fitGlmFixed', PACKAGE = 'RPEGLMEN', predictor_matrix, response_vector, alpha, num_lambda, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold)
.Call(`_RPEGLMEN_fitGlmFixed`, predictor_matrix, response_vector, alpha, num_lambda, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold)
}

fitGlmCv <- function(predictor_matrix, response_vector, alpha = 1, num_lambda = 100L, glm_type = 1L, max_iter = 100L, abs_tol = 1.0e-4, rel_tol = 1.0e-2, normalize_grad = FALSE, k_fold = 5L, has_intercept = TRUE, k_fold_iter = 5L) {
.Call('_RPEGLMEN_fitGlmCv', PACKAGE = 'RPEGLMEN', predictor_matrix, response_vector, alpha, num_lambda, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold, has_intercept, k_fold_iter)
.Call(`_RPEGLMEN_fitGlmCv`, predictor_matrix, response_vector, alpha, num_lambda, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold, has_intercept, k_fold_iter)
}

ExpNegativeLogLikelihood_cpp <- function(x, predictor_matrix, response_vector, alpha = 1, num_lambda = 100L, glm_type = 1L, max_iter = 100L, abs_tol = 1.0e-4, rel_tol = 1.0e-2, normalize_grad = FALSE, k_fold = 5L) {
.Call('_RPEGLMEN_ExpNegativeLogLikelihood_cpp', PACKAGE = 'RPEGLMEN', x, predictor_matrix, response_vector, alpha, num_lambda, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold)
.Call(`_RPEGLMEN_ExpNegativeLogLikelihood_cpp`, x, predictor_matrix, response_vector, alpha, num_lambda, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold)
}

GradExpNegativeLogLikelihood_cpp <- function(x, predictor_matrix, response_vector, alpha = 1, num_lambda = 100L, glm_type = 1L, max_iter = 100L, abs_tol = 1.0e-4, rel_tol = 1.0e-2, normalize_grad = FALSE, k_fold = 5L) {
.Call('_RPEGLMEN_GradExpNegativeLogLikelihood_cpp', PACKAGE = 'RPEGLMEN', x, predictor_matrix, response_vector, alpha, num_lambda, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold)
.Call(`_RPEGLMEN_GradExpNegativeLogLikelihood_cpp`, x, predictor_matrix, response_vector, alpha, num_lambda, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold)
}

ProxGradDescent_cpp <- function(predictor_matrix, response_vector, lambda = 0, alpha = 1, glm_type = 1L, max_iter = 100L, abs_tol = 1.0e-4, rel_tol = 1.0e-2, normalize_grad = FALSE, k_fold = 5L) {
.Call('_RPEGLMEN_ProxGradDescent_cpp', PACKAGE = 'RPEGLMEN', predictor_matrix, response_vector, lambda, alpha, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold)
.Call(`_RPEGLMEN_ProxGradDescent_cpp`, predictor_matrix, response_vector, lambda, alpha, glm_type, max_iter, abs_tol, rel_tol, normalize_grad, k_fold)
}

13 changes: 12 additions & 1 deletion R/glmGammaNet.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#' Fit glmnet model for Gamma distributed response data.
#' @useDynLib RPEGLMEN, .registration = TRUE
#' @importFrom Rcpp evalCpp
NULL
#'
#' @import stats
#' @import utils

#' @title Elastic Net Penalized Gamma or Exponentially Distributed Response Variables
#'
#' @description \code{git.glmGammaNet} Fit glmnet model for Gamma distributed response data.
#'
#' @param A The matrix of independent variables.
#' @param b The vector of response variables.
Expand All @@ -17,7 +26,9 @@
#' @param ... Additional parameters.
#'
#' @return vector of optimal coefficient for the glm model
#'
#' @export
#'
fit.glmGammaNet <- function(A,
b,
exponential.dist = FALSE,
Expand Down
6 changes: 4 additions & 2 deletions R/glmnet_exp.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
#' @param ... Additional Parameters.
#'
#' @return vector of optimal coefficient for the glm model
#'
#' @export
#'
glmnet_exp = function(A,
b,
...,
alpha.EN = 0.5,
num_lambda = 100L,
glm_type = 1L,
Expand All @@ -28,7 +29,8 @@ glmnet_exp = function(A,
normalize_grad = FALSE,
k_fold = 5L,
has_intercept = TRUE,
k_fold_iter = 5L){
k_fold_iter = 5L,
...){
return(fitGlmCv(A,
b,
alpha = alpha.EN,
Expand Down
Empty file modified cleanup
100644 → 100755
Empty file.
Empty file modified configure
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions man/fit.glmGammaNet.Rd

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

2 changes: 1 addition & 1 deletion src/GlmNetCpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* and open the template in the editor.
*/

#include "GlmNetCpp.h"
#include "GlmNetCpp.h"

GlmNetCpp::GlmNetCpp(const Eigen::MatrixXd& predictor_matrix,
const Eigen::VectorXd& response_vector, double alpha,
Expand Down
2 changes: 1 addition & 1 deletion src/GlmNetCpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/*
* File: glmnetcpp.h
* Author: Xin Chen
* Author: Xin Chen
*
* Created on June 2, 2017, 6:39 PM
*/
Expand Down
Binary file modified src/GlmNetCpp.o
Binary file not shown.
Binary file modified src/GlmNetCvCpp.o
Binary file not shown.
1 change: 0 additions & 1 deletion src/Makevars

This file was deleted.

12 changes: 12 additions & 0 deletions src/Makevars.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## With Rcpp 0.11.0 and later, we no longer need to set PKG_LIBS as there is
## no user-facing library. The include path to headers is already set by R.
#PKG_LIBS =

## With R 3.1.0 or later, you can uncomment the following line to tell R to
## enable compilation with C++11 (or even C++14) where available
CXX_STD = CXX11

PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -pthread
PKG_CFLAGS= -D__STDC_LIMIT_MACROS
PKG_CXXFLAGS= -D__STDC_LIMIT_MACROS
PKG_CPPFLAGS= -pthread
14 changes: 14 additions & 0 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## With Rcpp 0.11.0 and later, we no longer need to set PKG_LIBS as there is
## no user-facing library. The include path to headers is already set by R.
#PKG_LIBS =

## With R 3.1.0 or later, you can uncomment the following line to tell R to
## enable compilation with C++11 (or even C++14) where available
CXX_STD = CXX11

## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_PTHREAD_FLAGS)

PKG_CFLAGS= -D__STDC_LIMIT_MACROS
PKG_CXXFLAGS= -D__STDC_LIMIT_MACROS
PKG_CPPFLAGS= $(SHLIB_PTHREAD_FLAGS)
Binary file modified src/MyClass.o
Binary file not shown.
Binary file modified src/RcppExports.o
Binary file not shown.
2 changes: 1 addition & 1 deletion src/glmnetRcppInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Eigen::MatrixXd fitGlmFixed(const Eigen::MatrixXd& predictor_matrix,
return X;
}

// [[Rcpp::export]]
// [[Rcpp::export]]
Eigen::MatrixXd fitGlmCv(const Eigen::MatrixXd& predictor_matrix,
const Eigen::VectorXd& response_vector,
double alpha = 1, int num_lambda = 100, int glm_type = 1,
Expand Down
Binary file modified src/glmnetRcppInterface.o
Binary file not shown.

0 comments on commit efb2ff6

Please sign in to comment.