Skip to content

Commit

Permalink
Change name of vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
dppalomar committed May 3, 2018
1 parent 386ea47 commit f143f95
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 44 deletions.
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ RoxygenNote: 6.0.1
Suggests:
knitr,
rmarkdown,
bookdown,
prettydoc,
testthat,
MASS
VignetteBuilder: knitr
VignetteBuilder:
knitr,
bookdown,
prettydoc

4 changes: 2 additions & 2 deletions R/sparseEigen-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#' \href{https://cran.r-project.org/web/packages/sparseEigen/README.html}{CRAN-README}.
#'
#' For more details see the vignette:
#' \href{https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.html}{GitHub-html-vignette},
#' \href{https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.pdf}{GitHub-pdf-vignette}, and
#' \href{https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.html}{GitHub-html-vignette},
#' \href{https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.pdf}{GitHub-pdf-vignette}, and
#' \href{https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf}{CRAN-pdf-vignette}.
#'
#' @author Konstantinos Benidis and Daniel P. Palomar
Expand Down
8 changes: 4 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
output:
md_document:
variant: markdown_github
html_document:
variant: markdown_github
keep_md: true
md_document:
variant: markdown_github
---

<!-- README.md is generated from README.Rmd. Please edit that file -->
Expand Down Expand Up @@ -62,7 +62,7 @@ citation("sparseEigen")
```

## Vignette
For more detailed information, please check the vignette: [GitHub-html-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.html), [GitHub-pdf-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.pdf),
For more detailed information, please check the vignette: [GitHub-html-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.html), [GitHub-pdf-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.pdf),
[CRAN-pdf-vignette](https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf).

## Usage of `spEigen()`
Expand Down Expand Up @@ -165,5 +165,5 @@ Package: [CRAN](https://CRAN.R-project.org/package=sparseEigen) and [GitHub](htt

README file: [GitHub-readme](https://rawgit.com/dppalomar/sparseEigen/master/README.html) and [CRAN-readme](https://cran.r-project.org/web/packages/sparseEigen/README.html).

Vignette: [GitHub-html-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.html), [GitHub-pdf-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.pdf),
Vignette: [GitHub-html-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.html), [GitHub-pdf-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.pdf),
[CRAN-pdf-vignette](https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf).
4 changes: 2 additions & 2 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h2>Installation</h2>
</div>
<div id="vignette" class="section level2">
<h2>Vignette</h2>
<p>For more detailed information, please check the vignette: <a href="https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.html">GitHub-html-vignette</a>, <a href="https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.pdf">GitHub-pdf-vignette</a>, <a href="https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf">CRAN-pdf-vignette</a>.</p>
<p>For more detailed information, please check the vignette: <a href="https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.html">GitHub-html-vignette</a>, <a href="https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.pdf">GitHub-pdf-vignette</a>, <a href="https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf">CRAN-pdf-vignette</a>.</p>
</div>
<div id="usage-of-speigen" class="section level2">
<h2>Usage of <code>spEigen()</code></h2>
Expand Down Expand Up @@ -210,7 +210,7 @@ <h2>Usage of <code>spEigenCov()</code></h2>
<h2>Links</h2>
<p>Package: <a href="https://CRAN.R-project.org/package=sparseEigen">CRAN</a> and <a href="https://github.com/dppalomar/sparseEigen">GitHub</a>.</p>
<p>README file: <a href="https://rawgit.com/dppalomar/sparseEigen/master/README.html">GitHub-readme</a> and <a href="https://cran.r-project.org/web/packages/sparseEigen/README.html">CRAN-readme</a>.</p>
<p>Vignette: <a href="https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.html">GitHub-html-vignette</a>, <a href="https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.pdf">GitHub-pdf-vignette</a>, <a href="https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf">CRAN-pdf-vignette</a>.</p>
<p>Vignette: <a href="https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.html">GitHub-html-vignette</a>, <a href="https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.pdf">GitHub-pdf-vignette</a>, <a href="https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf">CRAN-pdf-vignette</a>.</p>
</div>
</div>

Expand Down
76 changes: 47 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
---
output:
html_document:
variant: markdown_github
keep_md: true
md_document:
variant: markdown_github
---

<!-- README.md is generated from README.Rmd. Please edit that file -->
sparseEigen
===========

Computation of sparse eigenvectors of a matrix (aka sparse PCA) with running time 2-3 orders of magnitude lower than existing methods and better final performance in terms of recovery of sparsity pattern and estimation of numerical values.

Can handle covariance matrices as well as data matrices with real or complex-valued entries. Different levels of sparsity can be specified for each individual ordered eigenvector and the method is robust in parameter selection. See vignette for a detailed documentation and comparison, with several illustrative examples.

The package is based on the paper: K. Benidis, Y. Sun, P. Babu, and D. P. Palomar (2016), "Orthogonal Sparse PCA and Covariance Estimation via Procrustes Reformulation," IEEE Transactions on Signal Processing, <https://doi.org/10.1109/TSP.2016.2605073>.
# sparseEigen

Computation of sparse eigenvectors of a matrix (aka sparse PCA)
with running time 2-3 orders of magnitude lower than existing methods and
better final performance in terms of recovery of sparsity pattern and
estimation of numerical values.

Can handle covariance matrices as well as data matrices with real or
complex-valued entries. Different levels of sparsity can be specified
for each individual ordered eigenvector and the method is robust in
parameter selection. See vignette for a detailed documentation and
comparison, with several illustrative examples.

The package is based on the paper:
K. Benidis, Y. Sun, P. Babu, and D. P. Palomar (2016), "Orthogonal Sparse PCA
and Covariance Estimation via Procrustes Reformulation," IEEE Transactions on
Signal Processing, <https://doi.org/10.1109/TSP.2016.2605073>.


Installation
------------
## Installation

``` r
```r
# Installation from CRAN
install.packages("sparseEigen")

Expand All @@ -29,17 +50,14 @@ package?sparseEigen
citation("sparseEigen")
```

Vignette
--------

For more detailed information, please check the vignette: [GitHub-html-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.html), [GitHub-pdf-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.pdf), [CRAN-pdf-vignette](https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf).

Usage of `spEigen()`
--------------------
## Vignette
For more detailed information, please check the vignette: [GitHub-html-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.html), [GitHub-pdf-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.pdf),
[CRAN-pdf-vignette](https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf).

## Usage of `spEigen()`
We start by loading the package and generating synthetic data with sparse eigenvectors:

``` r
```r
library(sparseEigen)
set.seed(42)

Expand All @@ -66,62 +84,62 @@ R <- V %*% diag(lmd) %*% t(V)
# with the constructed covariance matrix
X <- MASS::mvrnorm(n, rep(0, m), R) # random data with underlying sparse structure
```

Then, we estimate the covariance matrix with `cov(X)` and compute its sparse eigenvectors:

``` r
```r
# computation of sparse eigenvectors
res_standard <- eigen(cov(X))
res_sparse <- spEigen(cov(X), q)
```

We can assess how good the estimated eigenvectors are by computing the inner product with the original eigenvectors (the closer to 1 the better):

``` r
```r
# show inner product between estimated eigenvectors and originals
abs(diag(t(res_standard$vectors) %*% V[, 1:q])) #for standard estimated eigenvectors
#> [1] 0.9215392 0.9194898 0.9740871
abs(diag(t(res_sparse$vectors) %*% V[, 1:q])) #for sparse estimated eigenvectors
#> [1] 0.9986937 0.9988146 0.9972078
```

Finally, the following plot shows the sparsity pattern of the eigenvectors (sparse computation vs. classical computation): <img src="man/figures/README-unnamed-chunk-6-1.png" width="75%" style="display: block; margin: auto;" />
Finally, the following plot shows the sparsity pattern of the eigenvectors (sparse computation vs. classical computation):
<img src="man/figures/README-unnamed-chunk-6-1.png" width="75%" style="display: block; margin: auto;" />

Usage of `spEigenCov()`
-----------------------
## Usage of `spEigenCov()`

The function `spEigenCov()` requires more samples than the dimension (otherwise some regularization is required). Therefore, we generate data as previously with the only difference that we set the number of samples to be `n=600`.



Then, we compute the covariance matrix through the joint estimation of sparse eigenvectors and eigenvalues:

``` r
```r
# computation of covariance matrix
res_sparse2 <- spEigenCov(cov(X), q)
```

Again, we can assess how good the estimated eigenvectors are by computing the inner product with the original eigenvectors:

``` r
```r
# show inner product between estimated eigenvectors and originals
abs(diag(t(res_sparse2$vectors[, 1:q]) %*% V[, 1:q])) #for sparse estimated eigenvectors
#> [1] 0.9997197 0.9996029 0.9992848
```

Finally, we can compute the error of the estimated covariance matrix (sparse eigenvector computation vs. classical computation):

``` r
```r
# show error between estimated and true covariance
norm(cov(X) - R, type = 'F') #for sample covariance matrix
#> [1] 48.42514
norm(res_sparse2$cov - R, type = 'F') #for covariance with sparse eigenvectors
#> [1] 25.74865
```

Links
-----

## Links
Package: [CRAN](https://CRAN.R-project.org/package=sparseEigen) and [GitHub](https://github.com/dppalomar/sparseEigen).

README file: [GitHub-readme](https://rawgit.com/dppalomar/sparseEigen/master/README.html) and [CRAN-readme](https://cran.r-project.org/web/packages/sparseEigen/README.html).

Vignette: [GitHub-html-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.html), [GitHub-pdf-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors.pdf), [CRAN-pdf-vignette](https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf).
Vignette: [GitHub-html-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.html), [GitHub-pdf-vignette](https://rawgit.com/dppalomar/sparseEigen/master/vignettes/SparseEigenvectors-vignette.pdf),
[CRAN-pdf-vignette](https://cran.r-project.org/web/packages/sparseEigen/vignettes/SparseEigenvectors.pdf).
4 changes: 2 additions & 2 deletions man/sparseEigen-package.Rd

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

4 changes: 2 additions & 2 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SparseEigenvectors_cache
SparseEigenvectors_files
SparseEigenvectors-vignette_cache
SparseEigenvectors-vignette_files
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f143f95

Please sign in to comment.