Commit b8cc222a by Rauschenberger

### automation

parent 28293169
 ... ... @@ -16,7 +16,7 @@ #' covariates\strong{:} #' matrix with \eqn{n} rows (samples) and \eqn{p} columns (variables) #' #' @param nfold #' @param nfolds #' number of folds #' #' @param alpha ... ... @@ -30,12 +30,12 @@ #' #y[1] <- 0.5 #' #a <- glmnet::glmnet(y=y,x=x,family="binomial") #' #b <- stats::glm(y~x,family="binomial") colasso <- function(y,X,nfold=10,alpha=1){ colasso <- function(y,X,nfold=10,alpha=1,nfolds=10){ # properties n <- nrow(X); p <- ncol(X) if(length(y)!=n){stop("sample size")} foldid <- sample(x=rep(x=seq_len(nfold),length.out=n)) foldid <- sample(x=rep(x=seq_len(nfolds),length.out=n)) pi <- seq(from=0,to=0.5,by=0.1) # adapt this # model fitting ... ...
 ... ... @@ -120,7 +120,7 @@
colasso(y, X, nfold = 10, alpha = 1)
colasso(y, X, nfold = 10, alpha = 1, nfolds = 10)

Arguments

... ... @@ -135,14 +135,14 @@ vector of length $$n$$

covariates: matrix with $$n$$ rows (samples) and $$p$$ columns (variables)

nfold

number of folds

alpha

elastic net parameter

nfolds

number of folds

... ...
 ... ... @@ -5,7 +5,7 @@ \alias{colasso-package} \title{colasso} \usage{ colasso(y, X, nfold = 10, alpha = 1) colasso(y, X, nfold = 10, alpha = 1, nfolds = 10) } \arguments{ \item{y}{response\strong{:} ... ... @@ -14,9 +14,9 @@ vector of length \eqn{n}} \item{X}{covariates\strong{:} matrix with \eqn{n} rows (samples) and \eqn{p} columns (variables)} \item{nfold}{number of folds} \item{alpha}{elastic net parameter} \item{nfolds}{number of folds} } \description{ This function ... ... ...
 ... ... @@ -104,16 +104,16 @@ for(j in seq_len(ncol(Y))){ cat("| j =",j,"|\n") y <- Y[,j] if(sd(y,na.rm=TRUE)==0){next} #if(TRUE){ if(TRUE){ # psel <- sample(seq_len(56515),size=2000) # nsel <- sample(seq_len(2003),size=500) # y <- y[nsel] # x <- X[nsel,psel] #} nsel <- sample(seq_len(2003),size=500) y <- y[nsel] x <- X[nsel,] # psel } cond <- !is.na(y) y <- scale(y[cond]) x <- X[cond,] loss <- rbind(loss,colasso::colasso_compare(y=y,X=x)) x <- x[cond,] loss <- rbind(loss,colasso::colasso_compare(y=y,X=x,nfolds=5)) } ... ...
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