order
argument, then runs relaxnet in order to select a subset of the basis functions. Multiple values of order
and alpha
(the elastic net tuning parameter) may be specified, leading to selection of a specific value by cross-validation.
widenet(x, y, family = c("gaussian", "binomial"), order = 1:3, alpha = 1, nfolds = 10, foldid, screen.method = c("none", "cor", "ttest"), screen.num.vars = 50, multicore = FALSE, mc.cores, mc.seed = 123, ...)
widenet
function. Must have unique colnames.
family="gaussian"
. For family="binomial"
should be either a factor with two levels, or a two-column matrix of counts or proportions.
c(1, 2, 3)
. If there is more than one element, cross-validation is used to chose the order with best cross-validated performance.
glmnet
. If there is more than one element, cross-validation is used to chose the value with best cross-validated performance.
nfolds
can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable is nfolds=3
.
nfold
identifying what fold each observation is in. If supplied, nfolds
can be missing.
"cor"
= correlation, i.e. bivariate correlation with the outcome. ttest is meant for binary outcomes (family = "binomial"
). The screening methods are adapted from the SuperLearner package, the author of which is Eric Polley.
x
to screen in when using screening.
cv.relaxnet
) or over alpha values (for cv.alpha.relaxnet
) using multicore functionality from R's parallel package?
RNGkind
will be called to set the RNG to "L'Ecuyer-CMRG"
). Will be ignored if multicore
is FALSE
. If mulicore
is FALSE
, one should be able to get reprodicible results by setting the seed normally (with set.seed
) prior to running.
relaxnet
or cv.relaxnet
, which should also be passed on to glmnet
. Use with caution as this has not been tested.
"widenet"
with the following elements:order
argument
alpha
argument
screen.method
argument
x
, indicating those variables which were screened in for the run on the full data
ncol(x)
representing which of the columns of x
contained binary data. These columns will be represented by a 2. The other columns will have a 3.
"cv.relaxnet"
objects, one for each combination of values of alpha and order.
type.measure
argument has not yet been implemented. For type = gaussian models, mean squared error is used, and for type = binomial, binomial deviance is used.predict.widenet
, relaxnet
, cv.relaxnet
n <- 300
p <- 5
set.seed(23)
x <- matrix(rnorm(n*p), n, p)
colnames(x) <- paste("x", 1:ncol(x), sep = "")
y <- x[, 1] + x[, 2] + x[, 3] * x[, 4] + x[, 5]^2 + rnorm(n)
widenet.result <- widenet(x, y, family = "gaussian",
order = 2, alpha = 0.5)
summary(widenet.result)
coefs <- drop(predict(widenet.result, type = "coef"))
coefs[coefs != 0]
Run the code above in your browser using DataLab