Movatterモバイル変換


[0]ホーム

URL:


grpsel

R-CMD-checkcodecov

Overview

An R package for sparse regression modelling with grouped predictors(including overlapping groups).grpsel uses the groupsubset selection penalty, usually leading to excellent selection andprediction. Optionally, the group subset penalty can be combined with agroup lasso or ridge penalty for added shrinkage. Linear and logisticregression are currently supported. Seethis paper for moreinformation.

Installation

To install the latest stable version from CRAN, run the followingcode:

install.packages('grpsel')

To install the latest development version from GitHub, run thefollowing code:

devtools::install_github('ryan-thompson/grpsel')

Usage

Thegrpsel() function fits a group subset regressionmodel for a sequence of tuning parameters. Thecv.grpsel()function provides a convenient way to automatically cross-validate theseparameters.

library(grpsel)# Generate some grouped dataset.seed(123)n<-100# Number of observationsp<-10# Number of predictorsg<-5# Number of groupsgroup<-rep(1:g,each = p/ g)# Group structurebeta<-numeric(p)beta[which(group%in%1:2)]<-1# First two groups are nonzerox<-matrix(rnorm(n* p), n, p)y<- x%*% beta+rnorm(n)# Fit the group subset selection regularisation pathfit<-grpsel(x, y, group)coef(fit,lambda =0.05)
##            [,1]##  [1,] 0.1363219##  [2,] 1.0738565##  [3,] 0.9734311##  [4,] 0.8432186##  [5,] 1.1940502##  [6,] 0.0000000##  [7,] 0.0000000##  [8,] 0.0000000##  [9,] 0.0000000## [10,] 0.0000000## [11,] 0.0000000
# Cross-validate the group subset selection regularisation pathfit<-cv.grpsel(x, y, group)coef(fit)
##            [,1]##  [1,] 0.1363219##  [2,] 1.0738565##  [3,] 0.9734311##  [4,] 0.8432186##  [5,] 1.1940502##  [6,] 0.0000000##  [7,] 0.0000000##  [8,] 0.0000000##  [9,] 0.0000000## [10,] 0.0000000## [11,] 0.0000000

Documentation

See the packagevignetteorreferencemanual.


[8]ページ先頭

©2009-2025 Movatter.jp