Gitlab is now using https://gitlab.lcsb.uni.lu as it's primary address. Please update your bookmarks. FAQ.

Commit 43282c0c authored by Armin Rauschenberger's avatar Armin Rauschenberger
Browse files

competing models

parent 1e71f789
...@@ -5,7 +5,7 @@ Description: Implements high-dimensional multivariate regression by stacked gene ...@@ -5,7 +5,7 @@ Description: Implements high-dimensional multivariate regression by stacked gene
Depends: R (>= 3.0.0) Depends: R (>= 3.0.0)
Imports: glmnet, palasso, cornet Imports: glmnet, palasso, cornet
Suggests: knitr, testthat, MASS Suggests: knitr, testthat, MASS
Enhances: mice, earth, spls, MRCE, remMap, MultivariateRandomForest, SiER, MCEN, GPM, RMTL, MTPS Enhances: mice, earth, spls, MRCE, remMap, MultivariateRandomForest, SiER, mcen, GPM, RMTL, MTPS
Authors@R: person("Armin","Rauschenberger",email="armin.rauschenberger@uni.lu",role=c("aut","cre")) Authors@R: person("Armin","Rauschenberger",email="armin.rauschenberger@uni.lu",role=c("aut","cre"))
VignetteBuilder: knitr VignetteBuilder: knitr
License: GPL-3 License: GPL-3
......
...@@ -566,7 +566,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex ...@@ -566,7 +566,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
# check packages # check packages
pkgs <- .packages(all.available=TRUE) pkgs <- .packages(all.available=TRUE)
if(length(compare)>1 || compare==TRUE){ if(is.character(compare)){
for(i in seq_along(compare)){ for(i in seq_along(compare)){
pkg <- switch(compare[i],mnorm="glmnet",mars="earth",spls="spls", pkg <- switch(compare[i],mnorm="glmnet",mars="earth",spls="spls",
mrce="MRCE",map="remMap",mrf="MultivariateRandomForest", mrce="MRCE",map="remMap",mrf="MultivariateRandomForest",
...@@ -666,6 +666,13 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex ...@@ -666,6 +666,13 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
} else { } else {
stop("MARS requires either \"gaussian\" or \"binomial\" family.",call.=FALSE) stop("MARS requires either \"gaussian\" or \"binomial\" family.",call.=FALSE)
} }
## nk = min(200, max(20, 2 * ncol(x))) + 1
## nprune <- seq(from=2,to=nk,length.out=10)
## i.e. run earth/mars with tryCatch for each nprune
## and select run with best cvm (here gcv)
# tune nprune (use default nk)!
pred$mars[foldid.ext==i,] <- earth:::predict.earth(object=object,newdata=X1,type="response") pred$mars[foldid.ext==i,] <- earth:::predict.earth(object=object,newdata=X1,type="response")
end <- Sys.time() end <- Sys.time()
time$mars <- as.numeric(difftime(end,start,units="secs")) time$mars <- as.numeric(difftime(end,start,units="secs"))
...@@ -692,7 +699,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex ...@@ -692,7 +699,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
stop("MRCE requires \"gaussian\" family.",call.=FALSE) stop("MRCE requires \"gaussian\" family.",call.=FALSE)
} }
lam1 <- lam2 <- 10^seq(from=1,to=-4,length.out=11) lam1 <- lam2 <- 10^seq(from=1,to=-4,length.out=11)
invisible(utils::capture.output(trials <- lapply(lam2,function(x) tryCatch(expr=MRCE::mrce(X=X0,Y=y0,lam1.vec=lam1,lam2.vec=x,method="cv"),error=function(x) NULL)))) invisible(utils::capture.output(trials <- lapply(lam2,function(x) tryCatch(expr=MRCE::mrce(X=X0,Y=y0,lam1.vec=lam1,lam2.vec=x,method="cv",kfold=nfolds.int),error=function(x) NULL))))
cv.err <- sapply(trials,function(x) ifelse(is.null(x),Inf,min(x$cv.err))) cv.err <- sapply(trials,function(x) ifelse(is.null(x),Inf,min(x$cv.err)))
object <- trials[[which.min(cv.err)]] object <- trials[[which.min(cv.err)]]
pred$mrce[foldid.ext==i,] <- matrix(object$muhat,nrow=nrow(X1),ncol=q,byrow=TRUE) + X1 %*% object$Bhat pred$mrce[foldid.ext==i,] <- matrix(object$muhat,nrow=nrow(X1),ncol=q,byrow=TRUE) + X1 %*% object$Bhat
...@@ -708,9 +715,10 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex ...@@ -708,9 +715,10 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
} }
mean <- colMeans(y0) mean <- colMeans(y0)
y0s <- y0-matrix(data=mean,nrow=nrow(X0),ncol=ncol(y0),byrow=TRUE) y0s <- y0-matrix(data=mean,nrow=nrow(X0),ncol=ncol(y0),byrow=TRUE)
lamL1.v <- exp(seq(from=log(10),to=log(20),length.out=11)) #lamL1.v <- exp(seq(from=log(10),to=log(20),length.out=11)) # original
lamL1.v <- seq(from=0,to=20,length.out=11) # trial
lamL2.v <- seq(from=0,to=5,length.out=11) lamL2.v <- seq(from=0,to=5,length.out=11)
cv <- remMap::remMap.CV(X=X0,Y=y0s,lamL1.v=lamL1.v,lamL2.v=lamL2.v) cv <- remMap::remMap.CV(X=X0,Y=y0s,lamL1.v=lamL1.v,lamL2.v=lamL2.v,fold=nfolds.int)
#graphics::plot(x=lamL1.v,y=log(as.numeric(cv$ols.cv[,3]))) #graphics::plot(x=lamL1.v,y=log(as.numeric(cv$ols.cv[,3])))
index <- which(cv$ols.cv==min(cv$ols.cv),arr.ind=TRUE)[1,] index <- which(cv$ols.cv==min(cv$ols.cv),arr.ind=TRUE)[1,]
object <- remMap::remMap(X.m=X0,Y.m=y0s,lamL1=lamL1.v[index[1]],lamL2=lamL2.v[index[2]]) object <- remMap::remMap(X.m=X0,Y.m=y0s,lamL1=lamL1.v[index[1]],lamL2=lamL2.v[index[2]])
...@@ -740,7 +748,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex ...@@ -740,7 +748,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
if(any(family!="gaussian")){ if(any(family!="gaussian")){
stop("SiER requires \"gaussian\" family.",call.=FALSE) stop("SiER requires \"gaussian\" family.",call.=FALSE)
} }
invisible(utils::capture.output(object <- SiER::cv.SiER(X=X0,Y=y0,K.cv=3,upper.comp=10,thres=0.01))) invisible(utils::capture.output(object <- SiER::cv.SiER(X=X0,Y=y0,K.cv=3)))
# trial with K.cv=3 (for spped-up) # trial with K.cv=3 (for spped-up)
# use upper.comp=10 and thres=0.01 (changed for speed-up) # use upper.comp=10 and thres=0.01 (changed for speed-up)
pred$sier[foldid.ext==i,] <- SiER::pred.SiER(cv.fit=object,X.new=X1) pred$sier[foldid.ext==i,] <- SiER::pred.SiER(cv.fit=object,X.new=X1)
...@@ -802,7 +810,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex ...@@ -802,7 +810,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
seed <- .Random.seed seed <- .Random.seed
for(j in seq_along(Lam2_seq)){ for(j in seq_along(Lam2_seq)){
.Random.seed <- seed .Random.seed <- seed
cvMTL[[j]] <- RMTL::cvMTL(X=X0l,Y=y0l,type=type,Lam1_seq=Lam1_seq,Lam2=Lam2_seq[j]) cvMTL[[j]] <- RMTL::cvMTL(X=X0l,Y=y0l,type=type,Lam1_seq=Lam1_seq,Lam2=Lam2_seq[j],nfolds=nfolds.int)
} }
cvm <- vapply(X=cvMTL,FUN=function(x) min(x$cvm),FUN.VALUE=numeric(1)) cvm <- vapply(X=cvMTL,FUN=function(x) min(x$cvm),FUN.VALUE=numeric(1))
Lam1 <- cvMTL[[which.min(cvm)]]$Lam1.min Lam1 <- cvMTL[[which.min(cvm)]]$Lam1.min
...@@ -873,7 +881,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex ...@@ -873,7 +881,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
# now using cross-validation residual stacking (CVRS) # now using cross-validation residual stacking (CVRS)
} }
if(!is.null(compare)){cat("\n")} if(length(compare)>1){cat("\n")} # was !is.null(compare)
# --- development --- # --- development ---
......
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multivariate Elastic Net Regression • joinet</title>
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/spacelab/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/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="Multivariate Elastic Net Regression">
<meta property="og:description" content="joinet">
<!-- 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>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#toc">
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</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.4</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../reference/index.html">functions</a>
</li>
<li>
<a href="../articles/joinet.html">vignette</a>
</li>
<li>
<a href="../articles/article.html">article</a>
</li>
<li>
<a href="../news/index.html">news</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/joinet">
<span class="fa fa-github"></span>
</a>
</li>
<li>
<a href="https://cran.r-project.org/package=joinet">
<span class="fa fa-download"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1 data-toc-skip>Multivariate Elastic Net Regression</h1>
<small class="dont-index">Source: <a href="https://github.com/rauschenberger/joinet/blob/master/vignettes/joinet.Rmd"><code>vignettes/joinet.Rmd</code></a></small>
<div class="hidden name"><code>joinet.Rmd</code></div>
</div>
<div id="installation" class="section level2">
<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"><html><body><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></body></html></div>
<p>Or install the latest development version from <a href="https://github.com/rauschenberger/joinet">GitHub</a>:</p>
<div class="sourceCode" id="cb2"><html><body><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></body></html></div>
</div>
<div id="initialisation" class="section level2">
<h2 class="hasAnchor">
<a href="#initialisation" class="anchor"></a>Initialisation</h2>
<p>Load and attach the package:</p>
<div class="sourceCode" id="cb3"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">joinet</span>)</pre></body></html></div>
<p>And access the <a href="https://rauschenberger.github.io/joinet/">documentation</a>:</p>
<div class="sourceCode" id="cb4"><html><body><pre class="r">?<span class="no">joinet</span>
<span class="fu"><a href="https://rdrr.io/r/utils/help.html">help</a></span>(<span class="no">joinet</span>)
<span class="fu"><a href="https://rdrr.io/r/utils/browseVignettes.html">browseVignettes</a></span>(<span class="st">"joinet"</span>)</pre></body></html></div>
</div>
<div id="simulation" class="section level2">
<h2 class="hasAnchor">
<a href="#simulation" class="anchor"></a>Simulation</h2>
<p>For <code>n</code> samples, we simulate <code>p</code> inputs (features, covariates) and <code>q</code> outputs (outcomes, responses). We assume high-dimensional inputs (<code>p</code> <span class="math inline">\(\gg\)</span> <code>n</code>) and low-dimensional outputs (<code>q</code> <span class="math inline">\(\ll\)</span> <code>n</code>).</p>
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="no">n</span> <span class="kw">&lt;-</span> <span class="fl">100</span>
<span class="no">q</span> <span class="kw">&lt;-</span> <span class="fl">2</span>
<span class="no">p</span> <span class="kw">&lt;-</span> <span class="fl">500</span></pre></body></html></div>
<p>We simulate the <code>p</code> inputs from a multivariate normal distribution. For the mean, we use the <code>p</code>-dimensional vector <code>mu</code>, where all elements equal zero. For the covariance, we use the <code>p</code> <span class="math inline">\(\times\)</span> <code>p</code> matrix <code>Sigma</code>, where the entry in row <span class="math inline">\(i\)</span> and column <span class="math inline">\(j\)</span> equals <code>rho</code><span class="math inline">\(^{|i-j|}\)</span>. The parameter <code>rho</code> determines the strength of the correlation among the inputs, with small <code>rho</code> leading weak correlations, and large <code>rho</code> leading to strong correlations (0 &lt; <code>rho</code> &lt; 1). The input matrix <code>X</code> has <code>n</code> rows and <code>p</code> columns.</p>
<div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="no">mu</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html">rep</a></span>(<span class="fl">0</span>,<span class="kw">times</span><span class="kw">=</span><span class="no">p</span>)
<span class="no">rho</span> <span class="kw">&lt;-</span> <span class="fl">0.90</span>
<span class="no">Sigma</span> <span class="kw">&lt;-</span> <span class="no">rho</span>^<span class="fu"><a href="https://rdrr.io/r/base/MathFun.html">abs</a></span>(<span class="fu"><a href="https://rdrr.io/r/base/col.html">col</a></span>(<span class="fu"><a href="https://rdrr.io/r/base/diag.html">diag</a></span>(<span class="no">p</span>))-<span class="fu"><a href="https://rdrr.io/r/base/row.html">row</a></span>(<span class="fu"><a href="https://rdrr.io/r/base/diag.html">diag</a></span>(<span class="no">p</span>)))
<span class="no">X</span> <span class="kw">&lt;-</span> <span class="kw pkg">MASS</span><span class="kw ns">::</span><span class="fu"><a href="https://rdrr.io/pkg/MASS/man/mvrnorm.html">mvrnorm</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">n</span>,<span class="kw">mu</span><span class="kw">=</span><span class="no">mu</span>,<span class="kw">Sigma</span><span class="kw">=</span><span class="no">Sigma</span>)</pre></body></html></div>
<p>We simulate the input-output effects from independent Bernoulli distributions. The parameter <code>pi</code> determines the number of effects, with small <code>pi</code> leading to few effects, and large <code>pi</code> leading to many effects (0 &lt; <code>pi</code> &lt; 1). The scalar <code>alpha</code> represents the intercept, and the <code>p</code>-dimensional vector <code>beta</code> represents the slopes.</p>
<div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="no">pi</span> <span class="kw">&lt;-</span> <span class="fl">0.01</span>
<span class="no">alpha</span> <span class="kw">&lt;-</span> <span class="fl">0</span>
<span class="no">beta</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/Binomial.html">rbinom</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">p</span>,<span class="kw">size</span><span class="kw">=</span><span class="fl">1</span>,<span class="kw">prob</span><span class="kw">=</span><span class="no">pi</span>)</pre></body></html></div>
<p>From the intercept <code>alpha</code>, the slopes <code>beta</code> and the inputs <code>X</code>, we calculate the linear predictor, the <code>n</code>-dimensional vector <code>eta</code>. Rescale the linear predictor to make the effects weaker or stronger. Set the argument <code>family</code> to <code>"gaussian"</code>, <code>"binomial"</code>, or <code>"poisson"</code> to define the distribution. The <code>n</code> times <code>p</code> matrix <code>Y</code> represents the outputs. We assume the outcomes are <em>positively</em> correlated.</p>
<div class="sourceCode" id="cb8"><html><body><pre class="r"><span class="no">eta</span> <span class="kw">&lt;-</span> <span class="no">alpha</span> + <span class="no">X</span> <span class="kw">%*%</span> <span class="no">beta</span>
<span class="no">eta</span> <span class="kw">&lt;-</span> <span class="fl">1.5</span>*<span class="fu"><a href="https://rdrr.io/r/base/scale.html">scale</a></span>(<span class="no">eta</span>)
<span class="no">family</span> <span class="kw">&lt;-</span> <span class="st">"gaussian"</span>
<span class="kw">if</span>(<span class="no">family</span><span class="kw">==</span><span class="st">"gaussian"</span>){
<span class="no">mean</span> <span class="kw">&lt;-</span> <span class="no">eta</span>
<span class="no">Y</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">replicate</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">q</span>,<span class="kw">expr</span><span class="kw">=</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="no">mean</span>))
}
<span class="kw">if</span>(<span class="no">family</span><span class="kw">==</span><span class="st">"binomial"</span>){
<span class="no">prob</span> <span class="kw">&lt;-</span> <span class="fl">1</span>/(<span class="fl">1</span>+<span class="fu"><a href="https://rdrr.io/r/base/Log.html">exp</a></span>(-<span class="no">eta</span>))
<span class="no">Y</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">replicate</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">q</span>,<span class="kw">expr</span><span class="kw">=</span><span class="fu"><a href="https://rdrr.io/r/stats/Binomial.html">rbinom</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">n</span>,<span class="kw">size</span><span class="kw">=</span><span class="fl">1</span>,<span class="kw">prob</span><span class="kw">=</span><span class="no">prob</span>))
}
<span class="kw">if</span>(<span class="no">family</span><span class="kw">==</span><span class="st">"poisson"</span>){
<span class="no">lambda</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/Log.html">exp</a></span>(<span class="no">eta</span>)
<span class="no">Y</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">replicate</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">q</span>,<span class="kw">expr</span><span class="kw">=</span><span class="fu"><a href="https://rdrr.io/r/stats/Poisson.html">rpois</a></span>(<span class="kw">n</span><span class="kw">=</span><span class="no">n</span>,<span class="kw">lambda</span><span class="kw">=</span><span class="no">lambda</span>))
}
<span class="fu"><a href="https://rdrr.io/r/stats/cor.html">cor</a></span>(<span class="no">Y</span>)</pre></body></html></div>
</div>
<div id="application" class="section level2">
<h2 class="hasAnchor">
<a href="#application" class="anchor"></a>Application</h2>
<p>The function <code>joinet</code> fits univariate and multivariate regression. Set the argument <code>alpha.base</code> to 0 (ridge) or 1 (lasso).</p>
<div class="sourceCode" id="cb9"><html><body><pre class="r"><span class="no">object</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/joinet.html">joinet</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="no">family</span>)</pre></body></html></div>
<p>Standard methods are available. The function <code>predict</code> returns the predicted values from the univariate (<code>base</code>) and multivariate (<code>meta</code>) models. The function <code>coef</code> returns the estimated intercepts (<code>alpha</code>) and slopes (<code>beta</code>) from the multivariate model (input-output effects). And the function <code>weights</code> returns the weights from stacking (output-output effects).</p>
<div class="sourceCode" id="cb10"><html><body><pre class="r"><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/stats/coef.html">coef</a></span>(<span class="no">object</span>)
<span class="fu"><a href="https://rdrr.io/r/stats/weights.html">weights</a></span>(<span class="no">object</span>)</pre></body></html></div>
<p>The function <code>cv.joinet</code> compares the predictive performance of univariate (<code>base</code>) and multivariate (<code>meta</code>) regression by nested cross-validation. The argument <code>type.measure</code> determines the loss function.</p>
<div class="sourceCode" id="cb11"><html><body><pre class="r"><span class="fu"><a href="../reference/cv.joinet.html">cv.joinet</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="no">family</span>)</pre></body></html></div>
<pre><code>## [,1] [,2]
## base 1.204741 1.523550
## meta 1.185200 1.278125
## none 3.206394 3.495571</code></pre>
</div>
<div id="reference" class="section level2">
<h2 class="hasAnchor">
<a href="#reference" class="anchor"></a>Reference</h2>
<p>Armin Rauschenberger and Enrico Glaab (2020). “joinet: predicting correlated outcomes jointly to improve clinical prognosis”. <em>Manuscript in preparation.</em></p>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2>
</nav>
</div>
</div>
<footer><div class="copyright">
<p>Developed by <a href="https://rauschenberger.github.io">Armin Rauschenberger</a>.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
</div>
</footer>
</div>
</body>
</html>
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Changelog • joinet</title>
<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/spacelab/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>
<!-- bootstrap-toc -->
<link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>
<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/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="Changelog" />
<!-- 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>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#toc">
<div class="container template-news">
<header>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</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.4</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../reference/index.html">functions</a>
</li>
<li>
<a href="../articles/joinet.html">vignette</a>
</li>
<li>
<a href="../articles/article.html">article</a>
</li>
<li>
<a href="../news/index.html">news</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/rauschenberger/joinet">
<span class="fa fa-github"></span>
</a>
</li>
<li>
<a href="https://cran.r-project.org/package=joinet">
<span class="fa fa-download"></span>
</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header>
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1 data-toc-skip>Changelog <small></small></h1>
<small>Source: <a href='https://github.com/rauschenberger/joinet/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="joinet-004-2020-05-06" class="section level2">
<h2 class="hasAnchor">
<a href="#joinet-004-2020-05-06" class="anchor"></a>joinet 0.0.4 (2020-05-06)</h2>
<ul>
<li>added competing models</li>
</ul>
</div>
<div id="joinet-003-2019-11-12" class="section level2">
<h2 class="hasAnchor">
<a href="#joinet-003-2019-11-12" class="anchor"></a>joinet 0.0.3 (2019-11-12)</h2>
<ul>
<li>changed glmnet exports</li>
</ul>
</div>
<div id="joinet-002-2019-08-08" class="section level2">
<h2 class="hasAnchor">
<a href="#joinet-002-2019-08-08" class="anchor"></a>joinet 0.0.2 (2019-08-08)</h2>
<ul>
<li>performance comparison</li>
</ul>
</div>
<div id="joinet-001-2019-08-03" class="section level2">
<h2 class="hasAnchor">
<a href="#joinet-001-2019-08-03" class="anchor"></a>joinet 0.0.1 (2019-08-03)</h2>
<ul>
<li>first submission</li>
</ul>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">
<h2 data-toc-skip>Contents</h2>
</nav>
</div>
</div>
<footer>
<div class="copyright">
<p>Developed by <a href='https://rauschenberger.github.io'>Armin Rauschenberger</a>.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
</div>
</footer>
</div>
</body>
</html>
...@@ -4,5 +4,5 @@ pkgdown_sha: ~ ...@@ -4,5 +4,5 @@ pkgdown_sha: ~
articles: articles:
article: article.html article: article.html
joinet: joinet.html joinet: joinet.html
last_built: 2020-07-01T15:37Z last_built: 2020-07-02T16:34Z
...@@ -177,10 +177,11 @@ to open the vignette.</p> ...@@ -177,10 +177,11 @@ to open the vignette.</p>
<span class='co'># p x q matrix "beta": slopes</span> <span class='co'># p x q matrix "beta": slopes</span>
<span class='co'>#--- model comparison ---</span> <span class='co'>#--- model comparison ---</span>
<span class='no'>loss</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='cv.joinet.html'>cv.joinet</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'>loss</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='cv.joinet.html'>cv.joinet</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='error'>Error in if (!pkg %in% pkgs) { stop("Method \"", compare[i], "\" requires package \"", pkg, "\".", call. = FALSE)}: argument is of length zero</span></div><div class='input'># cross-validated loss
<span class='co'># cross-validated loss</span> # row "base": univariate
<span class='co'># row "base": univariate</span> # row "meta": multivariate
<span class='co'># row "meta": multivariate</span></div></pre>
</div></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top"> <nav id="toc" data-toggle="toc" class="sticky-top">
......
...@@ -165,110 +165,110 @@ with \(n\) rows (samples) and \(q\) columns (variables).</p> ...@@ -165,110 +165,110 @@ with \(n\) rows (samples) and \(q\) columns (variables).</p>
<span class='no'>Y</span>[,<span class='fl'>1</span>] <span class='kw'>&lt;-</span> <span class='fl'>1</span>*(<span class='no'>Y</span>[,<span class='fl'>1</span>]<span class='kw'>&gt;</span><span class='fu'><a href='https://rdrr.io/r/stats/median.html'>median</a></span>(<span class='no'>Y</span>[,<span class='fl'>1</span>])) <span class='no'>Y</span>[,<span class='fl'>1</span>] <span class='kw'>&lt;-</span> <span class='fl'>1</span>*(<span class='no'>Y</span>[,<span class='fl'>1</span>]<span class='kw'>&gt;</span><span class='fu'><a href='https://rdrr.io/r/stats/median.html'>median</a></span>(<span class='no'>Y</span>[,<span class='fl'>1</span>]))
<span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='joinet.html'>joinet</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='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"binomial"</span>,<span class='st'>"gaussian"</span>,<span class='st'>"gaussian"</span>)) <span class='no'>object</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='joinet.html'>joinet</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='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"binomial"</span>,<span class='st'>"gaussian"</span>,<span class='st'>"gaussian"</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>)</div><div class='output co'>#&gt; $base <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>)</div><div class='output co'>#&gt; $base
#&gt; [,1] [,2] [,3] #&gt; [,1] [,2] [,3]
#&gt; [1,] 0.41837245 -1.928585385 -2.49734037 #&gt; [1,] 0.8880859 4.167470686 3.9891323
#&gt; [2,] 0.73430703 -1.232615541 -1.92258279 #&gt; [2,] 0.8522805 5.339566777 4.0083957
#&gt; [3,] 0.89830295 2.189899197 1.90525393 #&gt; [3,] 0.1409537 -1.127906721 -1.1297818
#&gt; [4,] 0.89750302 2.620239322 3.16623238 #&gt; [4,] 0.5482139 0.509438091 0.3658942
#&gt; [5,] 0.75114829 0.007031193 -0.17521804 #&gt; [5,] 0.7212955 0.304478229 0.9022886
#&gt; [6,] 0.14470451 -2.282808008 -2.29598057 #&gt; [6,] 0.7586983 2.504868432 2.1100457
#&gt; [7,] 0.09766868 -1.173475809 -1.01900217 #&gt; [7,] 0.1873125 -3.108111939 -2.2772250
#&gt; [8,] 0.90945310 3.743238898 3.54799601 #&gt; [8,] 0.2306623 -1.070706980 -0.3363343
#&gt; [9,] 0.80093334 0.020539090 0.66028304 #&gt; [9,] 0.1047830 -2.822495027 -3.4160136
#&gt; [10,] 0.41399970 -2.478399066 -2.17809084 #&gt; [10,] 0.7379560 0.465976049 0.6822625
#&gt; [11,] 0.87769011 3.710699246 3.43305524 #&gt; [11,] 0.8896766 1.158775734 0.4838729
#&gt; [12,] 0.10649510 -0.594219557 -0.26688072 #&gt; [12,] 0.8359719 0.781709813 1.6460842
#&gt; [13,] 0.07607328 -4.684823994 -4.25280223 #&gt; [13,] 0.1160376 0.680443196 0.6246262
#&gt; [14,] 0.20653264 0.507040407 0.46010982 #&gt; [14,] 0.6756877 1.781633314 1.8216938
#&gt; [15,] 0.22855559 -0.707175402 -0.50492476 #&gt; [15,] 0.8400620 5.825804542 4.7541491
#&gt; [16,] 0.77487110 -1.108208462 -0.97986741 #&gt; [16,] 0.5643016 -0.091714995 -0.2942564
#&gt; [17,] 0.22673908 -1.104045322 -0.53058056 #&gt; [17,] 0.1739011 -2.563509736 -2.6076003
#&gt; [18,] 0.88702215 -0.008662017 0.05825129 #&gt; [18,] 0.9466982 5.526587288 5.9721775
#&gt; [19,] 0.44743009 1.637425052 0.93757078 #&gt; [19,] 0.1686037 -1.704229560 -2.1406879
#&gt; [20,] 0.39800750 -2.875874417 -3.01614676 #&gt; [20,] 0.1921496 -1.132857441 -1.2162503
#&gt; [21,] 0.16726717 -0.589831578 -0.90077905 #&gt; [21,] 0.2366729 -1.240646242 -1.9384757
#&gt; [22,] 0.64835839 -0.667092621 -0.74610665 #&gt; [22,] 0.1819760 -0.052046078 0.6508637