MyNixOS website logo
Description

Generalized Supervised Principal Component Regression.

Generalization of supervised principal component regression (SPCR; Bair et al., 2006, <doi:10.1198/016214505000000628>) to support continuous, binary, and discrete variables as outcomes and predictors (inspired by the 'superpc' R package <https://cran.r-project.org/package=superpc>).

Generalized Supervised Principal Component regression

An R package implementing a version of the Supervised Principal Component regression (SPCR, Bair et al., 2006) that allows for any measurement level of the dependent and independent variables. This package builds upon the method implemented in the R package superpc.

Details

SPCR regresses a dependent variable onto a few supervised principal components computed from a large set of predictors. The steps followed by SPCR are the following:

  1. Regress the dependent variable onto each column of a data set of p possible predictors via p simple linear regressions.
  2. Define a subset of the original p variables by discarding all variables whose univariate regression coefficient is less than a chosen threshold.
  3. Use the subset of original data to estimate q PCs.
  4. Regress the dependent variable onto the q PCs.

A key aspect of the method is that both the number of PCs and the threshold value can be determined by cross-validation. GSPCR extends SPCR by allowing the dependent variable to be of any measurement level (i.e., ratio, interval, ordinal, nominal) by introducing likelihood-based thresholds for the univariate regressions in step 1. Furthermore, GSPCR allows the predictors to be of any type by combining the PCAmix framework (Kiers, 1991; Chavent et al., 2017) with SPCR in step 3.

Features

The R package gspcr allows to:

  • Estimate the GSPCR model on a training data set;
  • Plot the cross-validation trends used to tune the threshold value and the number of PCs to compute;
  • Predict observations on both the training data and new, previously unseen, data

Installation

To install the latest version, run the following command in your R console:

devtools::install_github("EdoardoCostantini/gspcr")

Usage

To load the gspcr library in an R session and start using it:

library("gspcr")

To check an example of how to use the package, call the help file for the main function:

help("cv_gspcr")

You can also read the first draft of the package vignette by opening the file ./vignettes/main-features.html.

Check on how to cite the package with the R command:

citation("gspcr")

Development

Tests

This software uses unit tests to test whether the functions behave as expected. These tests are performed by using the test() function from the devtools R package. The workflow is the one established by the testthat R package. To run these tests:

  1. Install the devtools R package, if you do not have it already.

    install.packages("devtools")
    
  2. Then, you can test with the following command in the R console:

    devtools::check()
    

Vignettes

The vignettes for this package take a lot of time to compile. As a result, I adopted a two-step workflow:

  1. Modify the desired vignette in the .Rmd.orig format
  2. Use the rebuild-vignettes.R script to update the actual .Rmd vignette files

When testing, building, uploading the package, only the .Rmd versions of the vignettes will be compiled. These versions contain precompiled R code and plots so that the compilation time is minimized. This workflow is inspired by:

References

Bair E, Hastie T, Paul D, Tibshirani R (2006). “Prediction by supervised principal components.” J. Am. Stat. Assoc., 101(473), 119-137.

Chavent, M., Kuentz-Simonet, V., Labenne, A., & Saracco, J. (2014). Multivariate analysis of mixed data: The R package PCAmixdata. arXiv preprint arXiv:1411.4911.

Kiers, H. A. (1991). Simple structure in component analysis techniques for mixtures of qualitative and quantitative variables. Psychometrika, 56(2), 197-212.

Metadata

Version

0.9.5

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows