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

competing models

parent 1e71f789
......@@ -5,7 +5,7 @@ Description: Implements high-dimensional multivariate regression by stacked gene
Depends: R (>= 3.0.0)
Imports: glmnet, palasso, cornet
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"))
VignetteBuilder: knitr
License: GPL-3
......
......@@ -566,7 +566,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
# check packages
pkgs <- .packages(all.available=TRUE)
if(length(compare)>1 || compare==TRUE){
if(is.character(compare)){
for(i in seq_along(compare)){
pkg <- switch(compare[i],mnorm="glmnet",mars="earth",spls="spls",
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
} else {
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")
end <- Sys.time()
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
stop("MRCE requires \"gaussian\" family.",call.=FALSE)
}
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)))
object <- trials[[which.min(cv.err)]]
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
}
mean <- colMeans(y0)
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)
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])))
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]])
......@@ -740,7 +748,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
if(any(family!="gaussian")){
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)
# 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)
......@@ -802,7 +810,7 @@ cv.joinet <- function(Y,X,family="gaussian",nfolds.ext=5,nfolds.int=10,foldid.ex
seed <- .Random.seed
for(j in seq_along(Lam2_seq)){
.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))
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
# now using cross-validation residual stacking (CVRS)
}
if(!is.null(compare)){cat("\n")}
if(length(compare)>1){cat("\n")} # was !is.null(compare)
# --- development ---
......
This diff is collapsed.
<!-- 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: ~
articles:
article: article.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>
<span class='co'># p x q matrix "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.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='co'># cross-validated loss</span>
<span class='co'># row "base": univariate</span>
<span class='co'># row "meta": multivariate</span></div></pre>
<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
# row "base": univariate
# row "meta": multivariate
</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">
......
This diff is collapsed.
......@@ -158,11 +158,11 @@ in the row on the outcomes in the column.</p>
<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/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='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'>5</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='fu'><a href='https://rdrr.io/r/stats/weights.html'>weights</a></span>(<span class='no'>object</span>)</div><div class='output co'>#&gt; y1 y2 y3
#&gt; (Intercept) -0.04720442 -0.15165929 0.26901703
#&gt; V1 0.00000000 0.01158793 0.65726908
#&gt; V2 0.55230103 0.71134918 0.45932382
#&gt; V3 0.60228936 0.49505561 0.01764908</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; y1 y2 y3
#&gt; (Intercept) 0.08948253 -0.3500177 0.174461771
#&gt; V1 0.64280995 0.5995782 0.517048864
#&gt; V2 0.50278104 0.5009735 0.579513404
#&gt; V3 0.00000000 0.2489581 0.003901707</div><div class='input'>
</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
......
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