Skip to content

Commit

Permalink
version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Murat Genç authored and cran-robot committed Feb 6, 2024
0 parents commit 37ce98a
Show file tree
Hide file tree
Showing 57 changed files with 2,621 additions and 0 deletions.
27 changes: 27 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Package: fastliu
Title: Fast Functions for Liu Regression with Regularization Parameter
and Statistics
Version: 1.0
Date: 2024-02-02
Authors@R: c(
person("Murat", "Genç", role = c("aut", "cre"),
email="muratgenc@tarsus.edu.tr", comment=c(ORCID="0000-0002-6335-3044")),
person("Ömer", "Özbilen", role=c("aut"),
email="ozbilen@mersin.edu.tr"))
Maintainer: Murat Genç <muratgenc@tarsus.edu.tr>
Description: Efficient computation of the Liu regression coefficient paths, Liu-related statistics and
information criteria for a grid of the regularization parameter.
The computations are based on the 'C++' library 'Armadillo' through the 'R' package 'Rcpp'.
License: GPL (>= 3)
Encoding: UTF-8
NeedsCompilation: yes
RoxygenNote: 7.2.3
LinkingTo: Rcpp, RcppArmadillo
Imports: graphics, Rcpp, stats
Depends: R (>= 3.6)
Author: Murat Genç [aut, cre] (<https://orcid.org/0000-0002-6335-3044>),
Ömer Özbilen [aut]
LazyData: true
Packaged: 2024-02-04 19:11:27 UTC; murat
Repository: CRAN
Date/Publication: 2024-02-05 20:50:11 UTC
56 changes: 56 additions & 0 deletions MD5
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
74b4b66df5c021b7884ef3b74a5fced7 *DESCRIPTION
16dc7dea491fa838a3ecd77f68a9025b *NAMESPACE
0ebab3f0f79867c62b46f83798d73c6b *R/RcppExports.R
e49eae5899bbb66a4dbc0a19f47889e3 *R/coef-liureg.R
efd38d9e466e11ffbfc1fbbf10eec094 *R/covliureg.R
ecb219117f729a73e7e1121cbabc8440 *R/data.R
81f06170c6ef4e0c777d350da245cacc *R/diagHliureg.R
4b56832473d5183c20980cc28ebf8a3d *R/fastliu-package.R
aff7a0388da839f4093eb7ba172c7cd2 *R/fastliu.R
2c50ac796288f3253b3f2401ce860f59 *R/hatliureg.R
5c14818d3af8c0c9b209dd6098601a5d *R/infoliu.R
68c0db312d6e2c335667bbb9ae27ee2b *R/lamest.R
5539ddc99ef39d021ecf50759d0f579c *R/plotfuns-liureg.R
60f0e0f162c53ec6f28fcbaa1d890317 *R/predict-liureg.R
ae698fa20e716fa52e3a579bcd31718a *R/pressliu.R
aad43c6780353d16e29d5a4169290877 *R/print-liureg.R
7de47ec59dba5de475221258fa1ad53d *R/print-statliu.R
a56906452efe8b49c6cb9f411adc9efe *R/residuals-liureg.R
0841043bc196384d0f9cf7edf7b83304 *R/statliu.R
f8c24a9a67a58bf72802c9a4673ae7b9 *R/summary-liureg.R
f01682ffd9d5582c0d3b8a226f3c2b16 *build/partial.rdb
a6cecb1c44d71f78bd8a525fe3ff7cd4 *data/Hitters.rda
3364e51c4655d7fb57e47f9f6e577334 *man/Hitters.Rd
a1efb2f1d61dd7f1191431c867517b39 *man/coef.liureg.Rd
8c591280df6cafc48c4ec3472124659f *man/covliu.Rd
0798f4ca3333981802554054bda1a923 *man/diagHliu.Rd
4f47ef51d0550a2a3f4d41986a589c0b *man/fastliu-package.Rd
86f96a3e81816b40d6ed07e88783703d *man/hatliu.Rd
74c124e4cc7ee49cc48c1dc14aad0740 *man/infoliu.Rd
f4034546352d36584e3709a7045995e8 *man/lamest.Rd
ff7a5716b4f733e7c71821ae040fea9b *man/liureg.Rd
425eae5a79541a7ccc0f5a0b896023a1 *man/plot.liureg.Rd
32d2b20782bffbea9a345e947b86e1f7 *man/predict.liureg.Rd
bff94aad5c2d79113a2dae9a9633b751 *man/pressliu.Rd
7916e7dad03055bea679d94dfdac89e3 *man/print.liureg.Rd
1b800cd9ab154d5684721d9649c55216 *man/print.statliu.Rd
99a2a84c34aeb5a0416f3ac8b0cc74c6 *man/residuals.liureg.Rd
bb94c30340bd4c64ad5251d155d9f187 *man/statliu.Rd
496cffb364d906cc1fc0f2b2498a22e4 *man/summary.liureg.Rd
c89d6b95d18721894ab45341d0fbc7a6 *src/Makevars
c89d6b95d18721894ab45341d0fbc7a6 *src/Makevars.win
ba40cae73db8da4a6089b52044f83d0f *src/RcppExports.cpp
2777869b0bfd8419fecd3b0327cccdd1 *src/coefliureg.cpp
7b5e08051b70239e4baf68b24664a88e *src/coefliureg.h
c6c8b1fdbfda87be9c81c6643af5c62a *src/covliu.cpp
c2f91aa07e2f98b5958aacb58cf3a193 *src/diagH.cpp
7961987c40c57e2da075573916aa27a8 *src/hat.cpp
3fc003086ad9c922d7003abf52188116 *src/liuoptlam.cpp
0a66f18be79432898c61607e8fa5269f *src/liureg.cpp
ca6869893dffc71ec7f2941764b0e104 *src/liureg.h
4cf9f9d39f1a774dff24e98120ba2401 *src/liustats.cpp
a71c19610d77966ed9dbc27a37ef8d82 *src/predictliureg.cpp
0c21a96c6d5e34a94abc6b4e019b5374 *src/predictliureg.h
f1fb25fdf3c00efd9ac0e22becfd5723 *src/press.cpp
58158f23e13ef7cd9ddfd2d0568d15e3 *src/samp.cpp
b75b15d7319ac1e7df5336866bea5132 *src/samp.h
27 changes: 27 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by roxygen2: do not edit by hand

S3method(coef,liureg)
S3method(plot,liureg)
S3method(predict,liureg)
S3method(print,liureg)
S3method(print,statliu)
S3method(residuals,liureg)
S3method(summary,liureg)
export(covliu)
export(diagHliu)
export(hatliu)
export(infoliu)
export(lamest)
export(liureg)
export(pressliu)
export(statliu)
importFrom(Rcpp,sourceCpp)
importFrom(graphics,legend)
importFrom(graphics,matplot)
importFrom(graphics,mtext)
importFrom(graphics,text)
importFrom(stats,coef)
importFrom(stats,pnorm)
importFrom(stats,symnum)
importFrom(stats,var)
useDynLib(fastliu, .registration = TRUE)
39 changes: 39 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

coef_liureg <- function(obj) {
.Call(`_fastliu_coef_liureg`, obj)
}

covliucpp <- function(obj) {
.Call(`_fastliu_covliucpp`, obj)
}

diagHcpp <- function(obj) {
.Call(`_fastliu_diagHcpp`, obj)
}

hatcpp <- function(obj) {
.Call(`_fastliu_hatcpp`, obj)
}

liuoptlamcpp <- function(obj) {
.Call(`_fastliu_liuoptlamcpp`, obj)
}

liuregcpp <- function(Xmat, yvec, lambda, scale) {
.Call(`_fastliu_liuregcpp`, Xmat, yvec, lambda, scale)
}

liustatscpp <- function(obj) {
.Call(`_fastliu_liustatscpp`, obj)
}

predict_liureg <- function(obj, newdata) {
.Call(`_fastliu_predict_liureg`, obj, newdata)
}

pressliucpp <- function(obj) {
.Call(`_fastliu_pressliucpp`, obj)
}

29 changes: 29 additions & 0 deletions R/coef-liureg.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#' Extract coefficient estimates from a liureg object
#'
#' Prints coefficient estimates from a
#' fitted \code{liureg} object.
#'
#' @param object A \code{liureg} object.
#' @param ... Not used in this implementation.
#'
#' @method coef liureg
#'
#' @return The returned object is a data.frame containing the coefficients path.
#' @author Murat Genç
#' @export
#'
#' @seealso [liureg()], [predict()], [summary()], [pressliu()], [residuals()]
#' @examples
#' data("Hitters")
#' Hitters <- na.omit(Hitters)
#' X <- model.matrix(Salary ~ ., Hitters)[, -1]
#' y <- Hitters$Salary
#' lam <- seq(0, 1, 0.01)
#' liu.mod <- liureg(X, y, lam)
#' coef(liu.mod)
coef.liureg <- function(object, ...){
betaorj <- coef_liureg(object)
rownames(betaorj) <- c("Intercept", object$cnames)
colnames(betaorj) <- object$lnames
betaorj
}
82 changes: 82 additions & 0 deletions R/covliureg.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#' Covariance matrix based on a fitted liureg object.
#'
#' For a scalar or vector tuning parameter lambda,
#' the \code{covliureg} computes the covariance matrix
#' for the estimates of a Liu regression model.
#'
#' @param obj A \code{liureg} object.
#' @return The returned object is a list of the matrix of estimated covariances.
#' @author Murat Genç and Ömer Özbilen
#' @export
#'
#' @seealso [liureg()], [coef()], [predict()], [summary()], [pressliu()], [residuals()]
#' @examples
#' data("Hitters")
#' Hitters <- na.omit(Hitters)
#' X <- model.matrix(Salary ~ ., Hitters)[, -1]
#' y <- Hitters$Salary
#' lam <- seq(0, 1, 0.01)
#' liu.mod <- liureg(X, y, lam)
#' # List of covariance matrices for 101 lambda values
#' cov.mat <- covliu(liu.mod)
#' print(cov.mat$lam1)
covliu <- function(obj){
covliu <- covliucpp(obj)
names(covliu) <- obj$lnames
for(i in 1:length(covliu)){
rownames(covliu[[i]]) <- colnames(covliu[[i]]) <- obj$cnames
}
covliu
}




















































62 changes: 62 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#' Hitters
#'
#' Major League Baseball Data from the 1986 and 1987 seasons.
#'
#' @name Hitters
#' @format A data frame with 322 observations of major league players
#' on the following 20 variables with explanations.
#' \tabular{lll}{
#' \code{AtBat} \tab \tab Number of times at bat in 1986\cr
#' \tab \cr
#' \code{Hits} \tab \tab Number of hits in 1986\cr
#' \tab \cr
#' \code{HmRun} \tab \tab Number of home runs in 1986\cr
#' \tab \cr
#' \code{Runs} \tab \tab Number of runs in 1986\cr
#' \tab \cr
#' \code{RBI} \tab \tab Number of runs batted in 1986\cr
#' \tab \cr
#' \code{Walks} \tab \tab Number of walks in 1986\cr
#' \tab \cr
#' \code{Years} \tab \tab Number of years in the major leagues\cr
#' \tab \cr
#' \code{CAtBat} \tab \tab Number of times at bat during his career\cr
#' \tab \cr
#' \code{CHits} \tab \tab Number of hits during his career\cr
#' \tab \cr
#' \code{CHmRun} \tab \tab Number of home runs during his career\cr
#' \tab \cr
#' \code{CRuns} \tab \tab Number of runs during his career\cr
#' \tab \cr
#' \code{CRBI} \tab \tab Number of runs batted in during his career\cr
#' \tab \cr
#' \code{CWalks} \tab \tab Number of walks during his career\cr
#' \tab \cr
#' \code{League} \tab \tab A factor with levels A and N indicating player's league at the end of 1986\cr
#' \tab \cr
#' \code{Division} \tab \tab A factor with levels E and W indicating player's division at the end of 1986\cr
#' \tab \cr
#' \code{PutOuts} \tab \tab Number of put outs in 1986\cr
#' \tab \cr
#' \code{Assists} \tab \tab Number of assists in 1986\cr
#' \tab \cr
#' \code{Errors} \tab \tab Number of errors in 1986\cr
#' \tab \cr
#' \code{Salary} \tab \tab 1987 annual salary on opening day in thousands of dollars\cr
#' \tab \cr
#' \code{NewLeague} \tab \tab A factor with levels A and N indicating player's league at the beginning of 1987\cr
#' \tab \cr
#' }
#' @source The dataset was retrieved from the StatLib library maintained at
#' Carnegie Mellon University. This is part of the data used in the 1988
#' ASA Graphics Section Poster Session. The dataset is available in the R package
#' ISLR2 (James et al., 2022). For more details, see the book,
#' *An Introduction to Statistical Learning with applications in R*
#' by James et al. (2013).
#' @references James, G., Witten, D., Hastie, T., and Tibshirani, R. (2013).
#' An Introduction to Statistical Learning with applications in R,
#' \url{https://www.statlearning.com}, *Springer-Verlag*, New York.
#'
#' James G, Witten D, Hastie T, Tibshirani R (2022). *ISLR2: Introduction to Statistical Learning, Second Edition*.
#' R package version 1.3-2, \url{https://CRAN.R-project.org/package=ISLR2}.
NULL
35 changes: 35 additions & 0 deletions R/diagHliureg.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#' Diagonal Elements of the Hat Matrix
#'
#' For each value of the regularization parameter lambda,
#' \code{diagHliu} returns the diagonal elements of the hat matrix.
#' Unlike the \code{hatliu} function, only the diagonal
#' elements of the hat matrix are calculated, thus the
#' computation of diagonal elements is faster than \code{hatliu}.
#'
#' @param obj A \code{liureg} object
#'
#' @return The returned object is a matrix whose columns are the
#' diagonal elements of the hat matrix for each value of the
#' lambda regularization parameter.
#' @author Murat Genç
#' @export
#'
#' @seealso [liureg()], [summary()], [pressliu()], [residuals()]
#'
#' @examples
#' data("Hitters")
#' Hitters <- na.omit(Hitters)
#' X <- model.matrix(Salary ~ ., Hitters)[, -1]
#' y <- Hitters$Salary
#' lam <- seq(0, 1, 0.01)
#' liu.mod <- liureg(X, y, lam)
#' diagHliu(liu.mod)
diagHliu <- function(obj){
diagH <- diagHcpp(obj)
rownames(diagH) <- obj$rnames
colnames(diagH) <- obj$lnames
diagH
}



16 changes: 16 additions & 0 deletions R/fastliu-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
#' @importFrom Rcpp sourceCpp
#' @importFrom graphics legend
#' @importFrom graphics matplot
#' @importFrom graphics mtext
#' @importFrom graphics text
#' @importFrom stats coef
#' @importFrom stats pnorm
#' @importFrom stats symnum
#' @importFrom stats var
#' @useDynLib fastliu, .registration = TRUE
## usethis namespace: end
NULL
Loading

0 comments on commit 37ce98a

Please sign in to comment.