Commit 11277c2a authored by Armin Rauschenberger's avatar Armin Rauschenberger
Browse files

extension

parent 0b889801
This package was submitted to CRAN on 2021-03-09.
Once it is accepted, delete this file and tag the release (commit 0b88980).
Package: joinet
Version: 0.0.7
Version: 0.0.8
Title: Multivariate Elastic Net Regression
Description: Implements high-dimensional multivariate regression by stacked generalisation (Wolpert 1992 <doi:10.1016/S0893-6080(05)80023-1>). For positively correlated outcomes, a single multivariate regression is typically more predictive than multiple univariate regressions. Includes functions for model fitting, extracting coefficients, outcome prediction, and performance measurement. If required, install MRCE or remMap from GitHub (<https://github.com/cran/MRCE>, <https://github.com/cran/remMap>).
Depends: R (>= 3.0.0)
......
## joinet 0.0.8 (2021-06-16)
* extension (with weights, without constraints)
## joinet 0.0.6 (2020-11-18)
* conditional execution
......
File added
......@@ -17,8 +17,7 @@
#' @param Y
#' outputs\strong{:}
#' numeric matrix with \eqn{n} rows (samples)
#' and \eqn{q} columns (variables),
#' with positive correlation (see details)
#' and \eqn{q} columns (variables)
#'
#' @param X
#' inputs\strong{:}
......@@ -49,21 +48,40 @@
#' numeric between \eqn{0} (ridge) and \eqn{1} (lasso)
#'
#' @param alpha.meta
#' elastic net mixing parameter for meta learner\strong{:}
#' elastic net mixing parameter for meta learners\strong{:}
#' numeric between \eqn{0} (ridge) and \eqn{1} (lasso)
#'
#' @param constraint
#' non-negativity constraints\strong{:}
#' logical (see details)
#'
#' @param weight
#' inclusion/exclusion of variables\strong{:}
#' logical matrix with \eqn{q} rows and \eqn{p} columns,
#' or \code{NULL} (see details)
#'
#' @param ...
#' further arguments passed to \code{\link[glmnet]{glmnet}}
#'
#' @references
#' Armin Rauschenberger, Enrico Glaab (2020)
#' Armin Rauschenberger, Enrico Glaab (2021)
#' "Predicting correlated outcomes from molecular data"
#' \emph{Manuscript in preparation}.
#'
#' @details
#' \strong{correlation:}
#' The \eqn{q} outcomes should be positively correlated.
#' Avoid negative correlations by changing the sign of the variable.
#' \strong{non-negativity constraints:}
#' If it is reasonable to assume that the outcomes
#' are \emph{positively} correlated
#' (potentially after changing the sign of some outcomes)
#' we recommend to set \code{constraint=TRUE}.
#' Then non-negativity constraints are imposed on the meta learner.
#'
#' \strong{inclusion/exclusion of variables:}
#' The entry in the \eqn{j}th column and the \eqn{k}th row
#' indicates whether the \eqn{j}th feature may be used for
#' modelling the \eqn{k}th outcome
#' (where \eqn{0} means \code{FALSE} and
#' \eqn{1} means \code{TRUE}).
#'
#' \strong{elastic net:}
#' \code{alpha.base} controls input-output effects,
......@@ -99,10 +117,11 @@
#' \dontrun{
#' browseVignettes("joinet") # further examples}
#'
joinet <- function(Y,X,family="gaussian",nfolds=10,foldid=NULL,type.measure="deviance",alpha.base=1,alpha.meta=1,...){
joinet <- function(Y,X,family="gaussian",nfolds=10,foldid=NULL,type.measure="deviance",alpha.base=1,alpha.meta=1,constraint=TRUE,weight=NULL,...){
# IMPLEMENT CODE FOR CONSTRAINT AND WEIGHT!
#--- temporary ---
# family <- "gaussian"; nfolds <- 10; foldid <- NULL; type.measure <- "deviance"
# family <- "gaussian"; nfolds <- 10; foldid <- NULL; type.measure <- "deviance"; alpha.base <- alpha.meta <- 1; constraint <- TRUE; weight <- NULL
#--- checks ---
Y <- as.matrix(Y)
......@@ -110,16 +129,16 @@ joinet <- function(Y,X,family="gaussian",nfolds=10,foldid=NULL,type.measure="dev
cornet:::.check(x=Y,type="matrix",miss=TRUE)
### trial start ###
for(i in 1:(ncol(Y)-1)){
for(j in i:ncol(Y)){
cor <- stats::cor.test(Y[,i],Y[,j],use="pairwise.complete.obs")
if(cor$statistic<0 & cor$p.value<0.05){
warning(paste("Columns",i,"and",j,"are negatively correlated."))
if(constraint){
for(i in 1:(ncol(Y)-1)){
for(j in i:ncol(Y)){
cor <- stats::cor.test(Y[,i],Y[,j],use="pairwise.complete.obs")
if(cor$statistic<0 & cor$p.value<0.05){
warning(paste("Columns",i,"and",j,"are negatively correlated. Consider using constraint=FALSE."),call.=FALSE)
}
}
}
}
### trial end ###
#if(any(stats::cor(Y,use="pairwise.complete.obs")<0,na.rm=TRUE)){warning("Negative correlation!",call.=FALSE)}
cornet:::.check(x=X,type="matrix")
......@@ -130,6 +149,7 @@ joinet <- function(Y,X,family="gaussian",nfolds=10,foldid=NULL,type.measure="dev
cornet:::.check(x=type.measure,type="string",values=c("deviance","class","mse","mae")) # not auc (min/max confusion)
cornet:::.check(x=alpha.base,type="scalar",min=0,max=1)
cornet:::.check(x=alpha.meta,type="scalar",min=0,max=1)
cornet:::.check(x=weight,type="matrix",min=0,max=1,null=TRUE)
if(!is.null(c(list(...)$lower.limits,list(...)$upper.limits))){
stop("Reserved arguments \"lower.limits\" and \"upper.limits\".",call.=FALSE)
}
......@@ -139,6 +159,12 @@ joinet <- function(Y,X,family="gaussian",nfolds=10,foldid=NULL,type.measure="dev
q <- ncol(Y)
p <- ncol(X)
if(is.null(weight)){
pf <- matrix(1,nrow=q,ncol=p)
} else {
pf <- 1/weight
}
#--- family ---
if(length(family)==1){
family <- rep(family,times=q)
......@@ -160,7 +186,7 @@ joinet <- function(Y,X,family="gaussian",nfolds=10,foldid=NULL,type.measure="dev
for(i in seq_len(q)){
cond <- !is.na(Y[,i])
#if(sum(cond)==0){nlambda[i] <- 0; next}
base[[i]]$glmnet.fit <- glmnet::glmnet(y=Y[cond,i],x=X[cond,],family=family[i],alpha=alpha.base,...) # ellipsis
base[[i]]$glmnet.fit <- glmnet::glmnet(y=Y[cond,i],x=X[cond,],family=family[i],alpha=alpha.base,penalty.factor=pf[i,],...) # ellipsis
base[[i]]$lambda <- base[[i]]$glmnet.fit$lambda
nlambda[i] <- length(base[[i]]$glmnet.fit$lambda)
}
......@@ -180,7 +206,7 @@ joinet <- function(Y,X,family="gaussian",nfolds=10,foldid=NULL,type.measure="dev
for(i in seq_len(q)){
cond <- !is.na(Y0[,i])
#if(sum(cond)==0){next}
object <- glmnet::glmnet(y=Y0[cond,i],x=X0[cond,],family=family[i],alpha=alpha.base,...) # ellipsis
object <- glmnet::glmnet(y=Y0[cond,i],x=X0[cond,],family=family[i],alpha=alpha.base,penalty.factor=pf[i,],...) # ellipsis
temp <- stats::predict(object=object,newx=X1,type="link",
s=base[[i]]$glmnet.fit$lambda)
link[[i]][foldid==k,seq_len(ncol(temp))] <- temp
......@@ -208,7 +234,7 @@ joinet <- function(Y,X,family="gaussian",nfolds=10,foldid=NULL,type.measure="dev
for(i in seq_len(q)){
cond <- !is.na(Y[,i])
meta[[i]] <- glmnet::cv.glmnet(y=Y[cond,i],x=hat[cond,],
lower.limits=0, # important: 0
lower.limits=ifelse(constraint,0,-Inf), # important: 0 (was lower.limits=0)
upper.limits=Inf, # important: Inf
foldid=foldid[cond],
family=family[i],
......
......@@ -40,7 +40,7 @@ devtools::install_github("rauschenberger/joinet")
## Reference
Armin Rauschenberger and Enrico Glaab (2020). "Predicting correlated outcomes from molecular data". *Manuscript in preparation.*
Armin Rauschenberger and Enrico Glaab (2021). "Predicting correlated outcomes from molecular data". *Manuscript in preparation.*
[![CRAN version](https://www.r-pkg.org/badges/version/joinet)](https://CRAN.R-project.org/package=joinet)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/joinet)](https://CRAN.R-project.org/package=joinet)
......
......@@ -71,7 +71,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">joinet</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.7</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.8</span>
</span>
</div>
......@@ -96,13 +96,13 @@
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/joinet">
<span class="fa fa-github"></span>
<span class="fas fa-github"></span>
</a>
</li>
<li>
<a href="https://cran.r-project.org/package=joinet">
<span class="fa fa-download"></span>
<span class="fas fa-download"></span>
</a>
</li>
......@@ -142,7 +142,7 @@ Content not found. Please use links in the navbar.
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
......
......@@ -31,7 +31,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">joinet</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.7</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.8</span>
</span>
</div>
......@@ -56,13 +56,13 @@
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/joinet">
<span class="fa fa-github"></span>
<span class="fas fa-github"></span>
</a>
</li>
<li>
<a href="https://cran.r-project.org/package=joinet">
<span class="fa fa-download"></span>
<span class="fas fa-download"></span>
</a>
</li>
......@@ -76,7 +76,7 @@
</header><div class="row">
</header><script src="article_files/header-attrs-2.8/header-attrs.js"></script><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1 data-toc-skip>Multivariate Elastic Net Regression</h1>
......@@ -93,7 +93,7 @@
<div id="reference" class="section level2">
<h2 class="hasAnchor">
<a href="#reference" class="anchor"></a>Reference</h2>
<p>Armin Rauschenberger and Enrico Glaab (2020). “Predicting correlated outcomes from molecular data”. <em>Manuscript in preparation.</em></p>
<p>Armin Rauschenberger and Enrico Glaab (2021). “Predicting correlated outcomes from molecular data”. <em>Manuscript in preparation.</em></p>
</div>
</div>
......@@ -112,7 +112,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
......
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
// be compatible with the behavior of Pandoc < 2.8).
document.addEventListener('DOMContentLoaded', function(e) {
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
var i, h, a;
for (i = 0; i < hs.length; i++) {
h = hs[i];
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
a = h.attributes;
while (a.length > 0) h.removeAttribute(a[0].name);
}
});
......@@ -71,7 +71,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">joinet</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.7</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.8</span>
</span>
</div>
......@@ -96,13 +96,13 @@
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/joinet">
<span class="fa fa-github"></span>
<span class="fas fa-github"></span>
</a>
</li>
<li>
<a href="https://cran.r-project.org/package=joinet">
<span class="fa fa-download"></span>
<span class="fas fa-download"></span>
</a>
</li>
......@@ -145,7 +145,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
......
This diff is collapsed.
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
// be compatible with the behavior of Pandoc < 2.8).
document.addEventListener('DOMContentLoaded', function(e) {
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
var i, h, a;
for (i = 0; i < hs.length; i++) {
h = hs[i];
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
a = h.attributes;
while (a.length > 0) h.removeAttribute(a[0].name);
}
});
This source diff could not be displayed because it is too large. You can view the blob instead.
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
// be compatible with the behavior of Pandoc < 2.8).
document.addEventListener('DOMContentLoaded', function(e) {
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
var i, h, a;
for (i = 0; i < hs.length; i++) {
h = hs[i];
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
a = h.attributes;
while (a.length > 0) h.removeAttribute(a[0].name);
}
});
......@@ -71,7 +71,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">joinet</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.7</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.8</span>
</span>
</div>
......@@ -96,13 +96,13 @@
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/joinet">
<span class="fa fa-github"></span>
<span class="fas fa-github"></span>
</a>
</li>
<li>
<a href="https://cran.r-project.org/package=joinet">
<span class="fa fa-download"></span>
<span class="fas fa-download"></span>
</a>
</li>
......@@ -141,7 +141,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
......
......@@ -31,7 +31,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">joinet</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.7</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.8</span>
</span>
</div>
......@@ -56,13 +56,13 @@
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/joinet">
<span class="fa fa-github"></span>
<span class="fas fa-github"></span>
</a>
</li>
<li>
<a href="https://cran.r-project.org/package=joinet">
<span class="fa fa-download"></span>
<span class="fas fa-download"></span>
</a>
</li>
......@@ -89,10 +89,12 @@
<h2 class="hasAnchor">
<a href="#installation" class="anchor"></a>Installation</h2>
<p>Install the current release from <a href="https://CRAN.R-project.org/package=joinet">CRAN</a>:</p>
<div class="sourceCode" id="cb1"><pre class="r"><span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span>(<span class="st">"joinet"</span>)</pre></div>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"joinet"</span><span class="op">)</span></code></pre></div>
<p>or the latest development version from <a href="https://github.com/rauschenberger/joinet">GitHub</a>:</p>
<div class="sourceCode" id="cb2"><pre class="r"><span class="co">#install.packages("devtools")</span>
<span class="kw pkg">devtools</span><span class="kw ns">::</span><span class="fu"><a href="https://devtools.r-lib.org//reference/remote-reexports.html">install_github</a></span>(<span class="st">"rauschenberger/joinet"</span>)</pre></div>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co">#install.packages("devtools")</span>
<span class="fu">devtools</span><span class="fu">::</span><span class="fu"><a href="https://devtools.r-lib.org//reference/remote-reexports.html">install_github</a></span><span class="op">(</span><span class="st">"rauschenberger/joinet"</span><span class="op">)</span></code></pre></div>
</div>
<div id="reference" class="section level2">
<h2 class="hasAnchor">
......@@ -148,7 +150,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
......
......@@ -71,7 +71,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">joinet</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.7</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.0.8</span>
</span>
</div>
......@@ -96,13 +96,13 @@
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/joinet">
<span class="fa fa-github"></span>
<span class="fas fa-github"></span>
</a>
</li>
<li>
<a href="https://cran.r-project.org/package=joinet">
<span class="fa fa-download"></span>
<span class="fas fa-download"></span>
</a>
</li>
......@@ -123,6 +123,13 @@
<small>Source: <a href='https://github.com/rauschenberger/joinet/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="joinet-008-2021-06-16" class="section level2">
<h2 class="hasAnchor">
<a href="#joinet-008-2021-06-16" class="anchor"></a>joinet 0.0.8 (2021-06-16)</h2>
<ul>
<li>extension (with weights, without constraints)</li>
</ul>
</div>
<div id="joinet-006-2020-11-18" class="section level2">
<h2 class="hasAnchor">
<a href="#joinet-006-2020-11-18" class="anchor"></a>joinet 0.0.6 (2020-11-18)</h2>
......@@ -182,7 +189,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>
</footer>
......
......@@ -244,14 +244,14 @@ nav[data-toggle='toc'] .nav .nav > .active:focus > a {
.ref-index th {font-weight: normal;}
.ref-index td {vertical-align: top;}
.ref-index td {vertical-align: top; min-width: 100px}
.ref-index .icon {width: 40px;}
.ref-index .alias {width: 40%;}
.ref-index-icons .alias {width: calc(40% - 40px);}
.ref-index .title {width: 60%;}
.ref-arguments th {text-align: right; padding-right: 10px;}
.ref-arguments th, .ref-arguments td {vertical-align: top;}
.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px}
.ref-arguments .name {width: 20%;}
.ref-arguments .desc {width: 80%;}
......
pandoc: 2.7.2
pkgdown: 1.5.1
pandoc: 2.11.4
pkgdown: 1.6.1
pkgdown_sha: ~
articles:
article: article.html
joinet: joinet.html
script: script.html
last_built: 2021-03-09T07:43Z
last_built: 2021-06-16T07:04Z
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment