...
 
Commits (2)
Package: starnet
Version: 0.0.1
Title: Stacked Elastic Net
Description: Implements stacked elastic net regression. The elastic net generalises ridge and lasso regularisation (Zou 2005, <doi:10.1111/j.1467-9868.2005.00503.x>). Instead of fixing or tuning the mixing parameter alpha, we combine multiple alpha by stacked generalisation (Wolpert 1992 <doi:10.1016/S0893-6080(05)80023-1>).
Description: Implements stacked elastic net regression (Rauschenberger 2020). The elastic net generalises ridge and lasso regularisation (Zou 2005, <doi:10.1111/j.1467-9868.2005.00503.x>). Instead of fixing or tuning the mixing parameter alpha, we combine multiple alpha by stacked generalisation (Wolpert 1992 <doi:10.1016/S0893-6080(05)80023-1>).
Depends: R (>= 3.0.0)
Imports: glmnet, survival, palasso, cornet, joinet, CVXR, Matrix, mvtnorm
Suggests: knitr, testthat, MASS
......@@ -11,6 +11,6 @@ VignetteBuilder: knitr
License: GPL-3
LazyData: true
Language: en-GB
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
URL: https://github.com/rauschenberger/starnet
BugReports: https://github.com/rauschenberger/starnet/issues
......@@ -67,7 +67,7 @@
#' @references
#' A Rauschenberger, E Glaab, and MA van de Wiel (2020).
#' "Predictive and interpretable models via the stacked elastic net".
#' \emph{Manuscript in preparation.}
#' \emph{Bioinformatics}. In press.
#'
#' @details
#' Posthoc feature selection\strong{:} consider
......@@ -237,13 +237,13 @@ starnet <- function(y,X,family="gaussian",nalpha=21,alpha=NULL,nfolds=10,foldid=
#--- tune meta alpha ---
cvm_meta <- sapply(meta,function(x) min(x$cvm))
message(paste0(names(cvm_meta)," ",round(cvm_meta,digits=2)," "))
#message(paste0(names(cvm_meta)," ",round(cvm_meta,digits=2)," "))
id_meta <- which.min(cvm_meta)
#--- message ---
meta <- meta[[names(id_meta)]]
message(paste(paste(round(stats::coef(meta,s="lambda.min")[1],digits=3)),"_",
paste(round(stats::coef(meta,s="lambda.min")[-1],digits=3),collapse=" ")))
#message(paste(paste(round(stats::coef(meta,s="lambda.min")[1],digits=3)),"_",
# paste(round(stats::coef(meta,s="lambda.min")[-1],digits=3),collapse=" ")))
if(FALSE){
## debugging: stacking returns same output as tuning
......@@ -491,7 +491,12 @@ print.starnet <- function(x,...){
#' n <- 50; p <- 20
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
#' y <- rnorm(n=n,mean=rowSums(X[,1:20]))
#' \dontshow{
#' loss <- cv.starnet(y=y,X=X,nfolds.ext=2,nfolds.int=3)
#' }
#' \dontrun{
#' loss <- cv.starnet(y=y,X=X)
#' }
#'
cv.starnet <- function(y,X,family="gaussian",nalpha=21,alpha=NULL,nfolds.ext=10,nfolds.int=10,foldid.ext=NULL,foldid.int=NULL,type.measure="deviance",alpha.meta=1,nzero=NULL,intercept=NULL,upper.limit=NULL,unit.sum=NULL,...){
......
......@@ -24,7 +24,7 @@
#' @references
#' A Rauschenberger, E Glaab, and MA van de Wiel (2020).
#' Predictive and interpretable models via the stacked elastic net".
#' \emph{Manuscript in preparation}.
#' \emph{Bioinformatics}. In press.
#'
#' \email{armin.rauschenberger@uni.lu}
#'
......
......@@ -82,7 +82,7 @@
<h1>Stacked Elastic Net</h1>
<h4 class="author">Armin Rauschenberger</h4>
<h4 class="date">30 April 2020</h4>
<h4 class="date">16 May 2020</h4>
<small class="dont-index">Source: <a href="https://github.com/rauschenberger/starnet/blob/master/vignettes/script.Rmd"><code>vignettes/script.Rmd</code></a></small>
<div class="hidden name"><code>script.Rmd</code></div>
......
......@@ -96,7 +96,7 @@
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="kw"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span>(<span class="st">"starnet"</span>)</a></code></pre></div>
<p>or the latest development version from <a href="https://github.com/rauschenberger/starnet">GitHub</a>:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="co">#install.packages("devtools")</span></a>
<a class="sourceLine" id="cb2-2" title="2">devtools<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/devtools/man/remote-reexports.html">install_github</a></span>(<span class="st">"rauschenberger/starnet"</span>)</a></code></pre></div>
<a class="sourceLine" id="cb2-2" title="2">devtools<span class="op">::</span><span class="kw"><a href="https://devtools.r-lib.org//reference/remote-reexports.html">install_github</a></span>(<span class="st">"rauschenberger/starnet"</span>)</a></code></pre></div>
<p>A Rauschenberger, E Glaab, and MA van de Wiel (2020). “Predictive and interpretable models via the stacked elastic net”. <em>Manuscript in preparation.</em></p>
</div>
</div>
......
......@@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="pkgdown.css" rel="stylesheet">
<script src="pkgdown.js"></script><meta property="og:title" content="Stacked Elastic Net">
<meta property="og:description" content="Implements stacked elastic net regression. The elastic net generalises ridge and lasso regularisation (Zou 2005, &lt;doi:10.1111/j.1467-9868.2005.00503.x&gt;). Instead of fixing or tuning the mixing parameter alpha, we combine multiple alpha by stacked generalisation (Wolpert 1992 &lt;doi:10.1016/S0893-6080(05)80023-1&gt;).">
<meta property="og:description" content="Implements stacked elastic net regression (Rauschenberger 2020). The elastic net generalises ridge and lasso regularisation (Zou 2005, &lt;doi:10.1111/j.1467-9868.2005.00503.x&gt;). Instead of fixing or tuning the mixing parameter alpha, we combine multiple alpha by stacked generalisation (Wolpert 1992 &lt;doi:10.1016/S0893-6080(05)80023-1&gt;).">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
......@@ -92,7 +92,7 @@
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="kw"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span>(<span class="st">"starnet"</span>)</a></code></pre></div>
<p>or the latest development version from <a href="https://github.com/rauschenberger/starnet">GitHub</a>:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="co">#install.packages("devtools")</span></a>
<a class="sourceLine" id="cb2-2" title="2">devtools<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/devtools/man/remote-reexports.html">install_github</a></span>(<span class="st">"rauschenberger/starnet"</span>)</a></code></pre></div>
<a class="sourceLine" id="cb2-2" title="2">devtools<span class="op">::</span><span class="kw"><a href="https://devtools.r-lib.org//reference/remote-reexports.html">install_github</a></span>(<span class="st">"rauschenberger/starnet"</span>)</a></code></pre></div>
</div>
<div id="reference" class="section level2">
<h2 class="hasAnchor">
......
......@@ -155,7 +155,8 @@ positive integer, or <code>NULL</code></p></td>
<span class='no'>n</span> <span class='kw'>&lt;-</span> <span class='fl'>30</span>; <span class='no'>p</span> <span class='kw'>&lt;-</span> <span class='fl'>50</span>
<span class='no'>y</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='kw'>n</span><span class='kw'>=</span><span class='no'>n</span>)
<span class='no'>X</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/matrix.html'>matrix</a></span>(<span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='no'>n</span>*<span class='no'>p</span>),<span class='kw'>nrow</span><span class='kw'>=</span><span class='no'>n</span>,<span class='kw'>ncol</span><span class='kw'>=</span><span class='no'>p</span>)
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)</div><div class='output co'>#&gt; <span class='message'>alpha1 0.87 </span></div><div class='output co'>#&gt; <span class='message'>0.082 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='input'><span class='no'>coef</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/coef.html'>coef</a></span>(<span class='no'>object</span>)</div></pre>
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)
<span class='no'>coef</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/coef.html'>coef</a></span>(<span class='no'>object</span>)</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
......
docs/reference/cv.starnet-1.png

8.53 KB | W: | H:

docs/reference/cv.starnet-1.png

8.48 KB | W: | H:

docs/reference/cv.starnet-1.png
docs/reference/cv.starnet-1.png
docs/reference/cv.starnet-1.png
docs/reference/cv.starnet-1.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -126,11 +126,24 @@
<p>Compares stacked elastic net, tuned elastic net, ridge and lasso.</p>
</div>
<pre class="usage"><span class='fu'>cv.starnet</span>(<span class='no'>y</span>, <span class='no'>X</span>, <span class='kw'>family</span> <span class='kw'>=</span> <span class='st'>"gaussian"</span>, <span class='kw'>nalpha</span> <span class='kw'>=</span> <span class='fl'>21</span>, <span class='kw'>alpha</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>nfolds.ext</span> <span class='kw'>=</span> <span class='fl'>10</span>, <span class='kw'>nfolds.int</span> <span class='kw'>=</span> <span class='fl'>10</span>, <span class='kw'>foldid.ext</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>foldid.int</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>type.measure</span> <span class='kw'>=</span> <span class='st'>"deviance"</span>, <span class='kw'>alpha.meta</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>nzero</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>intercept</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>upper.limit</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>unit.sum</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
<pre class="usage"><span class='fu'>cv.starnet</span>(
<span class='no'>y</span>,
<span class='no'>X</span>,
<span class='kw'>family</span> <span class='kw'>=</span> <span class='st'>"gaussian"</span>,
<span class='kw'>nalpha</span> <span class='kw'>=</span> <span class='fl'>21</span>,
<span class='kw'>alpha</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>nfolds.ext</span> <span class='kw'>=</span> <span class='fl'>10</span>,
<span class='kw'>nfolds.int</span> <span class='kw'>=</span> <span class='fl'>10</span>,
<span class='kw'>foldid.ext</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>foldid.int</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>type.measure</span> <span class='kw'>=</span> <span class='st'>"deviance"</span>,
<span class='kw'>alpha.meta</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>nzero</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>intercept</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>upper.limit</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>unit.sum</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='no'>...</span>
)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
......@@ -226,8 +239,11 @@ or <code>NULL</code>
<span class='no'>n</span> <span class='kw'>&lt;-</span> <span class='fl'>50</span>; <span class='no'>p</span> <span class='kw'>&lt;-</span> <span class='fl'>20</span>
<span class='no'>X</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/matrix.html'>matrix</a></span>(<span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='no'>n</span>*<span class='no'>p</span>),<span class='kw'>nrow</span><span class='kw'>=</span><span class='no'>n</span>,<span class='kw'>ncol</span><span class='kw'>=</span><span class='no'>p</span>)
<span class='no'>y</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='kw'>n</span><span class='kw'>=</span><span class='no'>n</span>,<span class='kw'>mean</span><span class='kw'>=</span><span class='fu'><a href='https://rdrr.io/r/base/colSums.html'>rowSums</a></span>(<span class='no'>X</span>[,<span class='fl'>1</span>:<span class='fl'>20</span>]))
<span class='no'>loss</span> <span class='kw'>&lt;-</span> <span class='fu'>cv.starnet</span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)</div><div class='output co'>#&gt; <span class='message'>alpha1 2.63 </span></div><div class='output co'>#&gt; <span class='message'>0.003 _ 1 0.017 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.71 </span></div><div class='output co'>#&gt; <span class='message'>-0.022 _ 0.122 0.852 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.45 </span></div><div class='output co'>#&gt; <span class='message'>-0.03 _ 0.98 0.043 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.86 </span></div><div class='output co'>#&gt; <span class='message'>-0.082 _ 0.587 0.398 0 0 0 0 0 0 0 0 0 0.007 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.95 </span></div><div class='output co'>#&gt; <span class='message'>-0.133 _ 1 0.032 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.8 </span></div><div class='output co'>#&gt; <span class='message'>-0.111 _ 1 0.023 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.75 </span></div><div class='output co'>#&gt; <span class='message'>-0.05 _ 0.488 0.479 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.15 </span></div><div class='output co'>#&gt; <span class='message'>-0.031 _ 0 0.986 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.48 </span></div><div class='output co'>#&gt; <span class='message'>-0.08 _ 0.332 0.651 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 2.5 </span></div><div class='output co'>#&gt; <span class='message'>-0.038 _ 0.704 0.31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='img'><img src='cv.starnet-1.png' alt='' width='700' height='433' /></div><div class='input'>
</div></pre>
<span class='co'># \dontshow{</span>
<span class='no'>loss</span> <span class='kw'>&lt;-</span> <span class='fu'>cv.starnet</span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>,<span class='kw'>nfolds.ext</span><span class='kw'>=</span><span class='fl'>2</span>,<span class='kw'>nfolds.int</span><span class='kw'>=</span><span class='fl'>3</span>)</div><div class='img'><img src='cv.starnet-1.png' alt='' width='700' height='433' /></div><div class='input'><span class='co'># }</span>
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='no'>loss</span> <span class='kw'>&lt;-</span> <span class='fu'>cv.starnet</span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)
}</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
......
......@@ -127,8 +127,7 @@
</div>
<pre class="usage"><span class='co'># S3 method for starnet</span>
<span class='fu'><a href='https://rdrr.io/r/stats/predict.html'>predict</a></span>(<span class='no'>object</span>, <span class='no'>newx</span>, <span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"response"</span>,
<span class='kw'>nzero</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
<span class='fu'><a href='https://rdrr.io/r/stats/predict.html'>predict</a></span>(<span class='no'>object</span>, <span class='no'>newx</span>, <span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"response"</span>, <span class='kw'>nzero</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
......@@ -164,7 +163,8 @@ positive integer, or <code>NULL</code></p></td>
<span class='no'>n</span> <span class='kw'>&lt;-</span> <span class='fl'>30</span>; <span class='no'>p</span> <span class='kw'>&lt;-</span> <span class='fl'>50</span>
<span class='no'>y</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='kw'>n</span><span class='kw'>=</span><span class='no'>n</span>)
<span class='no'>X</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/matrix.html'>matrix</a></span>(<span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='no'>n</span>*<span class='no'>p</span>),<span class='kw'>nrow</span><span class='kw'>=</span><span class='no'>n</span>,<span class='kw'>ncol</span><span class='kw'>=</span><span class='no'>p</span>)
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)</div><div class='output co'>#&gt; <span class='message'>alpha1 0.87 </span></div><div class='output co'>#&gt; <span class='message'>0.082 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='input'><span class='no'>y_hat</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/predict.html'>predict</a></span>(<span class='no'>object</span>,<span class='kw'>newx</span><span class='kw'>=</span><span class='no'>X</span>[<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>1</span>),,<span class='kw'>drop</span><span class='kw'>=</span><span class='fl'>FALSE</span>])</div></pre>
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)
<span class='no'>y_hat</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/predict.html'>predict</a></span>(<span class='no'>object</span>,<span class='kw'>newx</span><span class='kw'>=</span><span class='no'>X</span>[<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>1</span>),,<span class='kw'>drop</span><span class='kw'>=</span><span class='fl'>FALSE</span>])</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
......
......@@ -148,7 +148,8 @@
<span class='no'>n</span> <span class='kw'>&lt;-</span> <span class='fl'>30</span>; <span class='no'>p</span> <span class='kw'>&lt;-</span> <span class='fl'>20</span>
<span class='no'>y</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='kw'>n</span><span class='kw'>=</span><span class='no'>n</span>)
<span class='no'>X</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/matrix.html'>matrix</a></span>(<span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='no'>n</span>*<span class='no'>p</span>),<span class='kw'>nrow</span><span class='kw'>=</span><span class='no'>n</span>,<span class='kw'>ncol</span><span class='kw'>=</span><span class='no'>p</span>)
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)</div><div class='output co'>#&gt; <span class='message'>alpha1 0.92 </span></div><div class='output co'>#&gt; <span class='message'>0.082 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='input'><span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span>(<span class='no'>object</span>)</div><div class='output co'>#&gt; stacked "gaussian" elastic net </div><div class='input'>
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)
<span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span>(<span class='no'>object</span>)</div><div class='output co'>#&gt; stacked "gaussian" elastic net </div><div class='input'>
</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
......
......@@ -146,7 +146,7 @@ to open the vignette.</p>
<p>A Rauschenberger, E Glaab, and MA van de Wiel (2020).
Predictive and interpretable models via the stacked elastic net".
<em>Manuscript in preparation</em>.</p>
<em>Bioinformatics</em>. In press.</p>
<p><a href='mailto:armin.rauschenberger@uni.lu'>armin.rauschenberger@uni.lu</a></p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
......@@ -157,7 +157,8 @@ Predictive and interpretable models via the stacked elastic net".
<span class='co'># n samples, p features</span>
<span class='co'>#--- model fitting ---</span>
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)</div><div class='output co'>#&gt; <span class='message'>alpha1 1.23 </span></div><div class='output co'>#&gt; <span class='message'>-0.249 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='input'><span class='co'># "base": one model for each alpha</span>
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)
<span class='co'># "base": one model for each alpha</span>
<span class='co'># "meta": model for stacking them </span>
<span class='co'>#--- make predictions ---</span>
......@@ -171,7 +172,7 @@ Predictive and interpretable models via the stacked elastic net".
<span class='co'># vector "beta": slopes</span>
<span class='co'>#--- model comparison ---</span>
<span class='no'>loss</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='cv.starnet.html'>cv.starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)</div><div class='output co'>#&gt; <span class='message'>alpha1 1.19 </span></div><div class='output co'>#&gt; <span class='message'>-0.12 _ 0 0 0 0 0 0 0 0.069 0 0 0.371 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 1.07 </span></div><div class='output co'>#&gt; <span class='message'>-0.196 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 1.23 </span></div><div class='output co'>#&gt; <span class='message'>-0.197 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 0.96 </span></div><div class='output co'>#&gt; <span class='message'>-0.023 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.021 1</span></div><div class='output co'>#&gt; <span class='message'>alpha1 1.14 </span></div><div class='output co'>#&gt; <span class='message'>-0.328 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 1.2 </span></div><div class='output co'>#&gt; <span class='message'>-0.009 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.997</span></div><div class='output co'>#&gt; <span class='message'>alpha1 1.13 </span></div><div class='output co'>#&gt; <span class='message'>-0.112 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.08 0.275 0 0.066 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 1.14 </span></div><div class='output co'>#&gt; <span class='message'>-0.07 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.604 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 1.22 </span></div><div class='output co'>#&gt; <span class='message'>-0.131 _ 0 0 0 0 0 0 0.465 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='output co'>#&gt; <span class='message'>alpha1 1.13 </span></div><div class='output co'>#&gt; <span class='message'>-0.264 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='img'><img src='starnet-package-1.png' alt='' width='700' height='433' /></div><div class='input'># cross-validated loss for different alpha,
<span class='no'>loss</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='cv.starnet.html'>cv.starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)</div><div class='img'><img src='starnet-package-1.png' alt='' width='700' height='433' /></div><div class='input'># cross-validated loss for different alpha,
# and for tuning and stacking
</div></pre>
......
......@@ -126,10 +126,22 @@
<p>Implements stacked elastic net regression.</p>
</div>
<pre class="usage"><span class='fu'>starnet</span>(<span class='no'>y</span>, <span class='no'>X</span>, <span class='kw'>family</span> <span class='kw'>=</span> <span class='st'>"gaussian"</span>, <span class='kw'>nalpha</span> <span class='kw'>=</span> <span class='fl'>21</span>, <span class='kw'>alpha</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>nfolds</span> <span class='kw'>=</span> <span class='fl'>10</span>, <span class='kw'>foldid</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>type.measure</span> <span class='kw'>=</span> <span class='st'>"deviance"</span>,
<span class='kw'>alpha.meta</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>penalty.factor</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>intercept</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>upper.limit</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>unit.sum</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
<pre class="usage"><span class='fu'>starnet</span>(
<span class='no'>y</span>,
<span class='no'>X</span>,
<span class='kw'>family</span> <span class='kw'>=</span> <span class='st'>"gaussian"</span>,
<span class='kw'>nalpha</span> <span class='kw'>=</span> <span class='fl'>21</span>,
<span class='kw'>alpha</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>nfolds</span> <span class='kw'>=</span> <span class='fl'>10</span>,
<span class='kw'>foldid</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>type.measure</span> <span class='kw'>=</span> <span class='st'>"deviance"</span>,
<span class='kw'>alpha.meta</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>penalty.factor</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>intercept</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>upper.limit</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>unit.sum</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='no'>...</span>
)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
......@@ -213,15 +225,14 @@ argument <code>nzero</code> in functions
<p>A Rauschenberger, E Glaab, and MA van de Wiel (2020).
"Predictive and interpretable models via the stacked elastic net".
<em>Manuscript in preparation.</em></p>
<em>Bioinformatics</em>. In press.</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><div class='input'><span class='fu'><a href='https://rdrr.io/r/base/Random.html'>set.seed</a></span>(<span class='fl'>1</span>)
<span class='no'>n</span> <span class='kw'>&lt;-</span> <span class='fl'>30</span>; <span class='no'>p</span> <span class='kw'>&lt;-</span> <span class='fl'>50</span>
<span class='no'>y</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='kw'>n</span><span class='kw'>=</span><span class='no'>n</span>)
<span class='no'>X</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/matrix.html'>matrix</a></span>(<span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='no'>n</span>*<span class='no'>p</span>),<span class='kw'>nrow</span><span class='kw'>=</span><span class='no'>n</span>,<span class='kw'>ncol</span><span class='kw'>=</span><span class='no'>p</span>)
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='kw pkg'>starnet</span><span class='kw ns'>::</span><span class='fu'><a href='https://rdrr.io/pkg/starnet/man/starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>,<span class='kw'>family</span><span class='kw'>=</span><span class='st'>"gaussian"</span>)</div><div class='output co'>#&gt; <span class='message'>alpha1 0.87 </span></div><div class='output co'>#&gt; <span class='message'>0.082 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='input'>
</div></pre>
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='kw pkg'>starnet</span><span class='kw ns'>::</span><span class='fu'><a href='https://rdrr.io/pkg/starnet/man/starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>,<span class='kw'>family</span><span class='kw'>=</span><span class='st'>"gaussian"</span>)</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
......
......@@ -150,7 +150,8 @@ i.e. the weights for the base learners.</p>
<span class='no'>n</span> <span class='kw'>&lt;-</span> <span class='fl'>30</span>; <span class='no'>p</span> <span class='kw'>&lt;-</span> <span class='fl'>50</span>
<span class='no'>y</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='kw'>n</span><span class='kw'>=</span><span class='no'>n</span>)
<span class='no'>X</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/matrix.html'>matrix</a></span>(<span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='no'>n</span>*<span class='no'>p</span>),<span class='kw'>nrow</span><span class='kw'>=</span><span class='no'>n</span>,<span class='kw'>ncol</span><span class='kw'>=</span><span class='no'>p</span>)
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)</div><div class='output co'>#&gt; <span class='message'>alpha1 0.87 </span></div><div class='output co'>#&gt; <span class='message'>0.082 _ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</span></div><div class='input'><span class='fu'><a href='https://rdrr.io/r/stats/weights.html'>weights</a></span>(<span class='no'>object</span>)</div><div class='output co'>#&gt; (Intercept) V1 V2 V3 V4 V5
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='starnet.html'>starnet</a></span>(<span class='kw'>y</span><span class='kw'>=</span><span class='no'>y</span>,<span class='kw'>X</span><span class='kw'>=</span><span class='no'>X</span>)
<span class='fu'><a href='https://rdrr.io/r/stats/weights.html'>weights</a></span>(<span class='no'>object</span>)</div><div class='output co'>#&gt; (Intercept) V1 V2 V3 V4 V5
#&gt; 0.08245817 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
#&gt; V6 V7 V8 V9 V10 V11
#&gt; 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
......
......@@ -4,11 +4,24 @@
\alias{cv.starnet}
\title{Model comparison}
\usage{
cv.starnet(y, X, family = "gaussian", nalpha = 21, alpha = NULL,
nfolds.ext = 10, nfolds.int = 10, foldid.ext = NULL,
foldid.int = NULL, type.measure = "deviance", alpha.meta = 1,
nzero = NULL, intercept = NULL, upper.limit = NULL,
unit.sum = NULL, ...)
cv.starnet(
y,
X,
family = "gaussian",
nalpha = 21,
alpha = NULL,
nfolds.ext = 10,
nfolds.int = 10,
foldid.ext = NULL,
foldid.int = NULL,
type.measure = "deviance",
alpha.meta = 1,
nzero = NULL,
intercept = NULL,
upper.limit = NULL,
unit.sum = NULL,
...
)
}
\arguments{
\item{y}{response\strong{:}
......@@ -76,6 +89,11 @@ set.seed(1)
n <- 50; p <- 20
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
y <- rnorm(n=n,mean=rowSums(X[,1:20]))
\dontshow{
loss <- cv.starnet(y=y,X=X,nfolds.ext=2,nfolds.int=3)
}
\dontrun{
loss <- cv.starnet(y=y,X=X)
}
}
......@@ -4,8 +4,7 @@
\alias{predict.starnet}
\title{Makes Predictions}
\usage{
\method{predict}{starnet}(object, newx, type = "response",
nzero = NULL, ...)
\method{predict}{starnet}(object, newx, type = "response", nzero = NULL, ...)
}
\arguments{
\item{object}{\link[starnet]{starnet} object}
......
......@@ -50,7 +50,7 @@ loss <- cv.starnet(y=y,X=X)
\references{
A Rauschenberger, E Glaab, and MA van de Wiel (2020).
Predictive and interpretable models via the stacked elastic net".
\emph{Manuscript in preparation}.
\emph{Bioinformatics}. In press.
\email{armin.rauschenberger@uni.lu}
}
......
......@@ -4,10 +4,22 @@
\alias{starnet}
\title{Stacked Elastic Net Regression}
\usage{
starnet(y, X, family = "gaussian", nalpha = 21, alpha = NULL,
nfolds = 10, foldid = NULL, type.measure = "deviance",
alpha.meta = 1, penalty.factor = NULL, intercept = NULL,
upper.limit = NULL, unit.sum = NULL, ...)
starnet(
y,
X,
family = "gaussian",
nalpha = 21,
alpha = NULL,
nfolds = 10,
foldid = NULL,
type.measure = "deviance",
alpha.meta = 1,
penalty.factor = NULL,
intercept = NULL,
upper.limit = NULL,
unit.sum = NULL,
...
)
}
\arguments{
\item{y}{response\strong{:}
......@@ -73,5 +85,5 @@ object <- starnet::starnet(y=y,X=X,family="gaussian")
\references{
A Rauschenberger, E Glaab, and MA van de Wiel (2020).
"Predictive and interpretable models via the stacked elastic net".
\emph{Manuscript in preparation.}
\emph{Bioinformatics}. In press.
}