cv.joinet {joinet} | R Documentation |
Model comparison
Description
Compares univariate and multivariate regression.
Usage
cv.joinet(
Y,
X,
family = "gaussian",
nfolds.ext = 5,
nfolds.int = 10,
foldid.ext = NULL,
foldid.int = NULL,
type.measure = "deviance",
alpha.base = 1,
alpha.meta = 1,
compare = FALSE,
mice = FALSE,
cvpred = FALSE,
times = FALSE,
...
)
Arguments
Y |
outputs:
numeric matrix with |
X |
inputs:
numeric matrix with |
family |
distribution:
vector of length |
nfolds.ext |
number of external folds |
nfolds.int |
number of internal folds |
foldid.ext |
external fold identifiers:
vector of length |
foldid.int |
internal fold identifiers:
vector of length |
type.measure |
loss function:
vector of length |
alpha.base |
elastic net mixing parameter for base learners:
numeric between |
alpha.meta |
elastic net mixing parameter for meta learners:
numeric between |
compare |
experimental arguments:
character vector with entries "mnorm", "spls", "mrce",
"sier", "mtps", "rmtl", "gpm" and others
(requires packages |
mice |
missing data imputation:
logical ( |
cvpred |
return cross-validated predictions: logical |
times |
measure computation time: logical |
... |
Value
This function returns a matrix with q
columns,
including the cross-validated loss from the univariate models
(base
), the multivariate models (meta
),
and the intercept-only models (none
).
Examples
## Not run:
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])))
cv.joinet(Y=Y,X=X)
## End(Not run)
## Not run:
# correlated features
n <- 50; p <- 100; q <- 3
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)])
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)
## End(Not run)
## Not run:
# other distributions
n <- 50; p <- 100; q <- 3
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
eta <- rowSums(X[,1:5])
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))))
cv.joinet(Y=Y,X=X,family="poisson")
## End(Not run)
## Not run:
# 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)
## End(Not run)
## Not run:
# 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
## End(Not run)