cv.joinet.Rd 3.73 KB
Newer Older
Armin Rauschenberger's avatar
Armin Rauschenberger committed
1 2
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
Armin Rauschenberger's avatar
Armin Rauschenberger committed
3 4
\name{cv.joinet}
\alias{cv.joinet}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
5 6
\title{Model comparison}
\usage{
Armin Rauschenberger's avatar
Armin Rauschenberger committed
7 8 9 10 11 12 13 14 15 16
cv.joinet(
  Y,
  X,
  family = "gaussian",
  nfolds.ext = 5,
  nfolds.int = 10,
  foldid.ext = NULL,
  foldid.int = NULL,
  type.measure = "deviance",
  alpha.base = 1,
Armin Rauschenberger's avatar
Armin Rauschenberger committed
17
  alpha.meta = 1,
Armin Rauschenberger's avatar
Armin Rauschenberger committed
18
  compare = FALSE,
Armin Rauschenberger's avatar
Armin Rauschenberger committed
19
  mice = FALSE,
Armin Rauschenberger's avatar
Armin Rauschenberger committed
20
  cvpred = FALSE,
Armin Rauschenberger's avatar
Armin Rauschenberger committed
21
  times = FALSE,
Armin Rauschenberger's avatar
Armin Rauschenberger committed
22 23
  ...
)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
}
\arguments{
\item{Y}{outputs\strong{:}
numeric matrix with \eqn{n} rows (samples)
and \eqn{q} columns (variables),
with positive correlation (see details)}

\item{X}{inputs\strong{:}
numeric matrix with \eqn{n} rows (samples)
and \eqn{p} columns (variables)}

\item{family}{distribution\strong{:}
vector of length \eqn{1} or \eqn{q} with entries
\code{"gaussian"}, \code{"binomial"} or \code{"poisson"}}

\item{nfolds.ext}{number of external folds}

\item{nfolds.int}{number of internal folds}

\item{foldid.ext}{external fold identifiers\strong{:}
vector of length \eqn{n} with entries
between \eqn{1} and \code{nfolds.ext};
or \code{NULL}}

\item{foldid.int}{internal fold identifiers\strong{:}
vector of length \eqn{n} with entries
between \eqn{1} and \code{nfolds.int};
or \code{NULL}}

\item{type.measure}{loss function\strong{:}
vector of length \eqn{1} or \eqn{q} with entries
\code{"deviance"}, \code{"class"}, \code{"mse"} or \code{"mae"}
(see \code{\link[glmnet]{cv.glmnet}})}

\item{alpha.base}{elastic net mixing parameter for base learners\strong{:}
numeric between \eqn{0} (ridge) and \eqn{1} (lasso)}

\item{alpha.meta}{elastic net mixing parameter for meta learner\strong{:}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
62
numeric between \eqn{0} (ridge) and \eqn{1} (lasso)}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
63

Armin Rauschenberger's avatar
Armin Rauschenberger committed
64 65 66 67
\item{compare}{experimental arguments\strong{:}
character vector with entries "mnorm", "spls", "mrce",
"sier", "mtps", "rmtl", "gpm" and others
(requires packages \code{spls}, \code{MRCE}, \code{SiER}, \code{MTPS}, \code{RMTL} or \code{GPM})}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
68

Armin Rauschenberger's avatar
Armin Rauschenberger committed
69 70 71
\item{mice}{missing data imputation\strong{:}
logical (\code{mice=TRUE} requires package \code{mice})}

Armin Rauschenberger's avatar
Armin Rauschenberger committed
72
\item{cvpred}{return cross-validated predictions: logical}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
73

Armin Rauschenberger's avatar
Armin Rauschenberger committed
74 75 76
\item{times}{measure computation time\strong{:}
logical}

Armin Rauschenberger's avatar
Armin Rauschenberger committed
77 78 79 80 81
\item{...}{further arguments passed to \code{\link[glmnet]{glmnet}}
and \code{\link[glmnet]{cv.glmnet}}}
}
\value{
This function returns a matrix with \eqn{q} columns,
Armin Rauschenberger's avatar
Armin Rauschenberger committed
82 83 84
including the cross-validated loss from the univariate models
(\code{base}), the multivariate models (\code{meta}),
and the intercept-only models (\code{none}).
Armin Rauschenberger's avatar
Armin Rauschenberger committed
85 86
}
\description{
Armin Rauschenberger's avatar
Armin Rauschenberger committed
87
Compares univariate and multivariate regression.
Armin Rauschenberger's avatar
Armin Rauschenberger committed
88 89
}
\examples{
Armin Rauschenberger's avatar
Armin Rauschenberger committed
90
n <- 50; p <- 100; q <- 3
Armin Rauschenberger's avatar
Armin Rauschenberger committed
91
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
92
Y <- replicate(n=q,expr=rnorm(n=n,mean=rowSums(X[,1:5])))
Armin Rauschenberger's avatar
Armin Rauschenberger committed
93
cv.joinet(Y=Y,X=X)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
94

Armin Rauschenberger's avatar
Armin Rauschenberger committed
95 96
\dontrun{
# correlated features
Armin Rauschenberger's avatar
Armin Rauschenberger committed
97
n <- 50; p <- 100; q <- 3
Armin Rauschenberger's avatar
Armin Rauschenberger committed
98 99 100 101
mu <- rep(0,times=p)
Sigma <- 0.90^abs(col(diag(p))-row(diag(p)))
X <- MASS::mvrnorm(n=n,mu=mu,Sigma=Sigma)
mu <- rowSums(X[,sample(seq_len(p),size=5)])
Armin Rauschenberger's avatar
Armin Rauschenberger committed
102 103 104
Y <- replicate(n=q,expr=rnorm(n=n,mean=mu))
#Y <- t(MASS::mvrnorm(n=q,mu=mu,Sigma=diag(n)))
cv.joinet(Y=Y,X=X)}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
105 106 107

\dontrun{
# other distributions
Armin Rauschenberger's avatar
Armin Rauschenberger committed
108
n <- 50; p <- 100; q <- 3
Armin Rauschenberger's avatar
Armin Rauschenberger committed
109
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
110
eta <- rowSums(X[,1:5])
Armin Rauschenberger's avatar
Armin Rauschenberger committed
111 112 113
Y <- replicate(n=q,expr=rbinom(n=n,size=1,prob=1/(1+exp(-eta))))
cv.joinet(Y=Y,X=X,family="binomial")
Y <- replicate(n=q,expr=rpois(n=n,lambda=exp(scale(eta))))
Armin Rauschenberger's avatar
Armin Rauschenberger committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
cv.joinet(Y=Y,X=X,family="poisson")}

\dontrun{
# uncorrelated outcomes
n <- 50; p <- 100; q <- 3
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
y <- rnorm(n=n,mean=rowSums(X[,1:5]))
Y <- cbind(y,matrix(rnorm(n*(q-1)),nrow=n,ncol=q-1))
cv.joinet(Y=Y,X=X)}

\dontrun{
# sparse and dense models
n <- 50; p <- 100; q <- 3
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
Y <- replicate(n=q,expr=rnorm(n=n,mean=rowSums(X[,1:5])))
set.seed(1) # fix folds
cv.joinet(Y=Y,X=X,alpha.base=1) # lasso
set.seed(1)
cv.joinet(Y=Y,X=X,alpha.base=0) # ridge}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
133

Armin Rauschenberger's avatar
Armin Rauschenberger committed
134
}