Commit 258b4761 authored by Armin Rauschenberger's avatar Armin Rauschenberger
Browse files

automation

parent beaeb072
#################
### cornet ###
#################
#--- generate toydata ----------------------------------------------------------
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/cornet/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "cornet"
#load("D:/cornet/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/cornet/cornet"
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::install(pkg=pkg,upgrade=FALSE)
#################
### cornet ###
#################
#--- generate toydata ----------------------------------------------------------
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/cornet/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "cornet"
#load("D:/cornet/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/cornet/cornet"
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::install(pkg=pkg,upgrade=FALSE)
remove.packages("colasso")
remove.packages("available")
remove.packages("bilasso")
remove.packages("cornet")
remove.packages("conet")
#################
### cornet ###
#################
#--- generate toydata ----------------------------------------------------------
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/cornet/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "cornet"
#load("D:/cornet/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/cornet/cornet"
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::install(pkg=pkg,upgrade=FALSE)
#################
### cornet ###
#################
#--- generate toydata ----------------------------------------------------------
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/cornet/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "cornet"
#load("D:/cornet/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/cornet/cornet"
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::install(pkg=pkg,upgrade=FALSE)
remove.packages("colasso")
......@@ -3,5 +3,5 @@
S3method(coef,cornet)
S3method(plot,cornet)
S3method(predict,cornet)
export(.compare)
export(cornet)
export(cornet_compare)
## colasso 0.0.0 (2019-01-08)
## cornet 0.0.0 (2019-01-17)
* Added functions
\ No newline at end of file
......@@ -21,6 +21,10 @@
#' numeric matrix with \eqn{n} rows (samples)
#' and \eqn{p} columns (variables)
#'
#' @param alpha
#' elastic net mixing parameter\strong{:}
#' numeric between \eqn{0} (ridge) and \eqn{1} (lasso)
#'
#' @param foldid
#' fold identifiers\strong{:}
#' vector with entries between \eqn{1} and \code{nfolds};
......@@ -64,7 +68,7 @@
#' X <- matrix(rnorm(n*p),nrow=n,ncol=p)
#' net <- cornet(y=y,cutoff=0,X=X)
#' ### Add ... to all glmnet::glmnet calls !!! ###
cornet <- function(y,cutoff,X,npi=101,pi=NULL,nsigma=99,sigma=NULL,nfolds=10,foldid=NULL,type.measure="deviance",...){
cornet <- function(y,cutoff,X,alpha=1,npi=101,pi=NULL,nsigma=99,sigma=NULL,nfolds=10,foldid=NULL,type.measure="deviance",...){
#--- temporary ---
# cutoff <- 0; npi <- 101; pi <- NULL; nsigma <- 99; sigma <- NULL; nfolds <- 10; foldid <- NULL; type.measure <- "deviance"; logistic <- TRUE
......@@ -77,6 +81,7 @@ cornet <- function(y,cutoff,X,npi=101,pi=NULL,nsigma=99,sigma=NULL,nfolds=10,fol
if(all(y %in% c(0,1))){warning("Binary response.",call.=FALSE)}
cornet:::.check(x=cutoff,type="scalar",min=min(y),max=max(y))
cornet:::.check(x=X,type="matrix")
cornet:::.check(x=alpha,type="scalar",min=0,max=1)
if(length(y)!=nrow(X)){stop("Contradictory sample size.",call.=FALSE)}
cornet:::.check(x=npi,type="scalar",min=1)
cornet:::.check(x=pi,type="vector",min=0,max=1,null=TRUE)
......@@ -98,8 +103,8 @@ cornet <- function(y,cutoff,X,npi=101,pi=NULL,nsigma=99,sigma=NULL,nfolds=10,fol
#--- model fitting ---
fit <- list()
fit$gaussian <- glmnet::glmnet(y=y,x=X,family="gaussian")
fit$binomial <- glmnet::glmnet(y=z,x=X,family="binomial")
fit$gaussian <- glmnet::glmnet(y=y,x=X,family="gaussian",alpha=alpha)
fit$binomial <- glmnet::glmnet(y=z,x=X,family="binomial",alpha=alpha)
#--- sigma sequence ---
if(is.null(sigma)){
......@@ -150,14 +155,14 @@ cornet <- function(y,cutoff,X,npi=101,pi=NULL,nsigma=99,sigma=NULL,nfolds=10,fol
X1 <- X[foldid==k,,drop=FALSE]
# linear regression
net <- glmnet::glmnet(y=y0,x=X0,family="gaussian")
net <- glmnet::glmnet(y=y0,x=X0,family="gaussian",alpha=alpha)
temp_y <- stats::predict(object=net,newx=X1,type="response",s=fit$gaussian$lambda)
pred$y[foldid==k,seq_len(ncol(temp_y))] <- temp_y
cvm <- cornet:::.loss(y=y1,fit=temp_y,family="gaussian",type.measure="deviance")[[1]]
y_hat <- temp_y[,which.min(cvm)]
# logistic regression
net <- glmnet::glmnet(y=z0,x=X0,family="binomial")
net <- glmnet::glmnet(y=z0,x=X0,family="binomial",alpha=alpha)
temp_z <- stats::predict(object=net,newx=X1,type="response",s=fit$binomial$lambda)
pred$z[foldid==k,seq_len(ncol(temp_z))] <- temp_z
cvm <- cornet:::.loss(y=z1,fit=temp_z,family="binomial",type.measure=type.measure)[[1]]
......@@ -399,7 +404,7 @@ predict.cornet <- function(object,newx,type="probability",...){
#' @examples
#' NA
#'
cornet_compare <- function(y,cutoff,X,nfolds=5,foldid=NULL,type.measure="deviance"){
.compare <- function(y,cutoff,X,alpha=1,nfolds=5,foldid=NULL,type.measure="deviance"){
z <- 1*(y > cutoff)
if(is.null(foldid)){
......@@ -415,7 +420,7 @@ cornet_compare <- function(y,cutoff,X,nfolds=5,foldid=NULL,type.measure="devianc
select <- list()
for(i in seq_len(nfolds)){
fit <- cornet::cornet(y=y[fold!=i],cutoff=cutoff,X=X[fold!=i,],logistic=TRUE,type.measure=type.measure)
fit <- cornet::cornet(y=y[fold!=i],cutoff=cutoff,X=X[fold!=i,],alpha=alpha,logistic=TRUE,type.measure=type.measure)
tryCatch(expr=cornet:::plot.cornet(fit),error=function(x) NULL)
#cornet:::plot.cornet(fit)
temp <- cornet:::predict.cornet(fit,newx=X[fold==i,])
......
......@@ -101,9 +101,9 @@
<small>Source: <a href='https://github.com/rauschenberger/colasso/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="colasso-0-0-0-2019-01-08" class="section level2">
<div id="cornet-0-0-0-2019-01-17" class="section level2">
<h2 class="hasAnchor">
<a href="#colasso-0-0-0-2019-01-08" class="anchor"></a>colasso 0.0.0 (2019-01-08)</h2>
<a href="#cornet-0-0-0-2019-01-17" class="anchor"></a>cornet 0.0.0 (2019-01-17)</h2>
<ul>
<li>Added functions</li>
</ul>
......@@ -114,7 +114,7 @@
<div id="tocnav">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#colasso-0-0-0-2019-01-08">0.0.0</a></li>
<li><a href="#cornet-0-0-0-2019-01-17">0.0.0</a></li>
</ul>
</div>
</div>
......
......@@ -111,7 +111,7 @@
</div>
<pre class="usage"><span class='fu'>cornet</span>(<span class='no'>y</span>, <span class='no'>cutoff</span>, <span class='no'>X</span>, <span class='kw'>npi</span> <span class='kw'>=</span> <span class='fl'>101</span>, <span class='kw'>pi</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>nsigma</span> <span class='kw'>=</span> <span class='fl'>99</span>,
<pre class="usage"><span class='fu'>cornet</span>(<span class='no'>y</span>, <span class='no'>cutoff</span>, <span class='no'>X</span>, <span class='kw'>alpha</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>npi</span> <span class='kw'>=</span> <span class='fl'>101</span>, <span class='kw'>pi</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>nsigma</span> <span class='kw'>=</span> <span class='fl'>99</span>,
<span class='kw'>sigma</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='no'>...</span>)</pre>
......@@ -133,6 +133,11 @@ value between <code>min(y)</code> and <code>max(y)</code></p></td>
<td><p>covariates<strong>:</strong>
numeric matrix with \(n\) rows (samples)
and \(p\) columns (variables)</p></td>
</tr>
<tr>
<th>alpha</th>
<td><p>elastic net mixing parameter<strong>:</strong>
numeric between \(0\) (ridge) and \(1\) (lasso)</p></td>
</tr>
<tr>
<th>npi</th>
......
......@@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Comparison — cornet_compare • cornet</title>
<title>Comparison — .compare • cornet</title>
<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script>
......@@ -30,7 +30,7 @@
<meta property="og:title" content="Comparison — cornet_compare" />
<meta property="og:title" content="Comparison — .compare" />
<meta property="og:description" content="Compares models for a continuous response with a cutoff value" />
<meta name="twitter:card" content="summary" />
......@@ -102,7 +102,7 @@
<div class="page-header">
<h1>Comparison</h1>
<small class="dont-index">Source: <a href='https://github.com/rauschenberger/colasso/blob/master/R/functions.R'><code>R/functions.R</code></a></small>
<div class="hidden name"><code>cornet_compare.Rd</code></div>
<div class="hidden name"><code>dot-compare.Rd</code></div>
</div>
<div class="ref-description">
......@@ -111,7 +111,7 @@
</div>
<pre class="usage"><span class='fu'>cornet_compare</span>(<span class='no'>y</span>, <span class='no'>cutoff</span>, <span class='no'>X</span>, <span class='kw'>nfolds</span> <span class='kw'>=</span> <span class='fl'>5</span>, <span class='kw'>foldid</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<pre class="usage"><span class='fu'>.compare</span>(<span class='no'>y</span>, <span class='no'>cutoff</span>, <span class='no'>X</span>, <span class='kw'>alpha</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>nfolds</span> <span class='kw'>=</span> <span class='fl'>5</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>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
......@@ -132,6 +132,11 @@ value between <code>min(y)</code> and <code>max(y)</code></p></td>
<td><p>covariates<strong>:</strong>
numeric matrix with \(n\) rows (samples)
and \(p\) columns (variables)</p></td>
</tr>
<tr>
<th>alpha</th>
<td><p>elastic net mixing parameter<strong>:</strong>
numeric between \(0\) (ridge) and \(1\) (lasso)</p></td>
</tr>
<tr>
<th>nfolds</th>
......
......@@ -130,15 +130,15 @@
</tr><tr>
<td>
<p><code><a href="cornet_compare.html">cornet_compare()</a></code> </p>
<p><code><a href="dot-check.html">.check()</a></code> </p>
</td>
<td><p>Comparison</p></td>
<td><p>Arguments</p></td>
</tr><tr>
<td>
<p><code><a href="dot-check.html">.check()</a></code> </p>
<p><code><a href="dot-compare.html">.compare()</a></code> </p>
</td>
<td><p>Arguments</p></td>
<td><p>Comparison</p></td>
</tr><tr>
<td>
......
......@@ -4,7 +4,7 @@
\alias{cornet}
\title{Logistic regression with a continuous response}
\usage{
cornet(y, cutoff, X, npi = 101, pi = NULL, nsigma = 99,
cornet(y, cutoff, X, alpha = 1, npi = 101, pi = NULL, nsigma = 99,
sigma = NULL, nfolds = 10, foldid = NULL,
type.measure = "deviance", ...)
}
......@@ -19,6 +19,9 @@ value between \code{min(y)} and \code{max(y)}}
numeric matrix with \eqn{n} rows (samples)
and \eqn{p} columns (variables)}
\item{alpha}{elastic net mixing parameter\strong{:}
numeric between \eqn{0} (ridge) and \eqn{1} (lasso)}
\item{npi}{number of \code{pi} values}
\item{pi}{pi sequence\strong{:}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
\name{cornet_compare}
\alias{cornet_compare}
\name{.compare}
\alias{.compare}
\title{Comparison}
\usage{
cornet_compare(y, cutoff, X, nfolds = 5, foldid = NULL,
.compare(y, cutoff, X, alpha = 1, nfolds = 5, foldid = NULL,
type.measure = "deviance")
}
\arguments{
......@@ -18,6 +18,9 @@ value between \code{min(y)} and \code{max(y)}}
numeric matrix with \eqn{n} rows (samples)
and \eqn{p} columns (variables)}
\item{alpha}{elastic net mixing parameter\strong{:}
numeric between \eqn{0} (ridge) and \eqn{1} (lasso)}
\item{nfolds}{number of folds}
\item{foldid}{fold identifiers\strong{:}
......
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