-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 04de362
Showing
18 changed files
with
1,882 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Package: relaxnet | ||
Type: Package | ||
Title: Relaxation of glmnet models (as in relaxed lasso, Meinshausen | ||
2007) | ||
Version: 0.2-1 | ||
Date: 2013-05-13 | ||
Author: Stephan Ritter, Alan Hubbard | ||
Maintainer: Stephan Ritter <sritter@berkeley.edu> | ||
Depends: glmnet | ||
Description: Extends the glmnet package with "relaxation", done by | ||
running glmnet once on the entire predictor matrix, then again | ||
on each different subset of variables from along the | ||
regularization path. Penalty may be lasso (alpha = 1) or | ||
elastic net (0 < alpha < 1). For this version, family may be | ||
"gaussian" or "binomial" only. Takes advantage of fast fortran | ||
code from the glmnet package. | ||
License: GPL (>= 2) | ||
URL: http://cran.r-project.org/package=relaxnet | ||
Packaged: 2013-05-13 21:40:05 UTC; sritter | ||
NeedsCompilation: no | ||
Repository: CRAN | ||
Date/Publication: 2013-05-13 23:52:22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
a2c733d9ae7a1c2eaa0e7cf73a75aac4 *DESCRIPTION | ||
7afafe46a8546a6f224388bb49f5d341 *NAMESPACE | ||
41866d4c1eaaca6c0b5a9e00ed354666 *R/cv.alpha.relaxnet.R | ||
ecfce34e5e1be0d6718b4d266b65885f *R/cv.relaxnet.R | ||
23d16565b304d04a74137e58b3cbe7a0 *R/predict.cv.alpha.relaxnet.R | ||
bfb5e07567c1a5c5747a4c75de823b4c *R/predict.cv.relaxnet.R | ||
398b60ed5e0ac6382f9b12dcc84910cb *R/predict.relaxnet.R | ||
bf7e8e9a2cdbd9e83d3c4a26b1be7879 *R/relaxnet.R | ||
4efc47e59cf8a1c03bade4913fb40555 *R/summary.relaxnet.R | ||
bab5e49d10753fa8c957e2298ac7d5c1 *R/zzz.R | ||
8185686dc82a5973a10b2799e33ced8d *man/cv.relaxnet.Rd | ||
53194f7662da0108e326dad35f6d21a1 *man/predict.cv.relaxnet.Rd | ||
7da35c54ba9cd9c3eed0f4c9bd5225d9 *man/predict.relaxnet.Rd | ||
470500c73bfd1037fd576df5cd430354 *man/print.relaxnet.Rd | ||
42389059fc67a5834a10967b9fb0660a *man/relaxnet-package.Rd | ||
bf6bc30c4b073b514201095f9a12e7e0 *man/relaxnet.Rd | ||
ac3047db141412ed844e061eb841882a *man/summary.relaxnet.Rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export(relaxnet, cv.relaxnet, cv.alpha.relaxnet) | ||
S3method(summary, relaxnet) | ||
S3method(print, relaxnet) | ||
S3method(print, summary.relaxnet) | ||
S3method(predict, relaxnet) | ||
S3method(predict, cv.relaxnet) | ||
S3method(predict, cv.alpha.relaxnet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
################################################################################ | ||
|
||
## cross-validation (on both lambda and alpha) for relaxnet models | ||
## adapted from the cv.glmnet function from package glmnet | ||
|
||
cv.alpha.relaxnet <- function(x, y, family = c("gaussian", "binomial"), | ||
nlambda = 100, | ||
alpha = c(.1, .3, .5, .7, .9), | ||
|
||
relax = TRUE, | ||
relax.nlambda = 100, | ||
relax.max.vars = min(nrow(x), ncol(x)) * 0.8, | ||
|
||
lambda = NULL, | ||
relax.lambda.index = NULL, | ||
relax.lambda.list = NULL, | ||
|
||
##type.measure=c("mse","deviance","class","auc","mae"), | ||
## just set it in code for now | ||
|
||
nfolds = 10, | ||
foldid, | ||
|
||
...) { | ||
|
||
start.time <- Sys.time() | ||
|
||
family = match.arg(family) | ||
|
||
## do something with this if including type.measure as an arg | ||
|
||
## if(family == "gaussian") type.measure <- "mse" | ||
## if(family == "binomial") type.measure <- "deviance" | ||
|
||
N=nrow(x) | ||
|
||
if(missing(foldid)) { | ||
|
||
## check nfolds here | ||
|
||
foldid <- sample(rep(seq(nfolds), length=N)) | ||
|
||
}## else { | ||
|
||
## check foldid | ||
|
||
## } | ||
|
||
if(relax && ncol(x) == 1) { | ||
|
||
warning("x has only one column, setting relax to FALSE") | ||
relax <- FALSE | ||
} | ||
|
||
cv.relaxnet.results <- | ||
|
||
lapply(alpha, | ||
function(alpha.val) { | ||
|
||
cv.relaxnet(x, y, family, | ||
nlambda, | ||
alpha.val, | ||
relax, | ||
relax.nlambda, | ||
relax.max.vars, | ||
lambda, | ||
relax.lambda.index, | ||
relax.lambda.list, | ||
foldid = foldid, | ||
...) | ||
}) | ||
|
||
alpha.min.index <- which.min(sapply(cv.relaxnet.results, function(cv.result) cv.result$min.cvm)) | ||
|
||
end.time <- Sys.time() | ||
|
||
obj <- list(call = match.call(), | ||
relax = relax, | ||
alpha = alpha, | ||
cv.relaxnet.results = cv.relaxnet.results, | ||
which.alpha.min = alpha[alpha.min.index], | ||
total.time = as.double(difftime(end.time, start.time, | ||
units = "secs"))) | ||
|
||
class(obj) <- "cv.alpha.relaxnet" | ||
|
||
obj | ||
} |
Oops, something went wrong.