gendata | R Documentation |
This function generates x/y data for testing sparsenet and glmnet
gendata(N, p, nonzero, rho, snr = 3, alternate = TRUE)
N |
Sample size (eg 500) |
p |
Number of features or variables (eg 1000) |
nonzero |
Number if nonzero coefficients (eg 30) |
rho |
pairwise correlation between features |
snr |
Signal to noise ratio - SD signal/ SD noise - try 3 |
alternate |
Alternate sign of coefficients |
Generates Gaussian x and y data. The nonzero coefficients decrease
linearly in absolute value from nonzero down to 0. If
alternate=TRUE
their signs alternate, else not
A list with components x and y as well some other details about the dataset
Trevor Hastie and Jerome Friedman
train.data=gendata(100,1000,nonzero=30,rho=0.3,snr=3)
fit=sparsenet(train.data$x,train.data$y)
par(mfrow=c(3,3))
plot(fit)
par(mfrow=c(1,1))
fitcv=cv.sparsenet(train.data$x,train.data$y,trace.it=TRUE)
plot(fitcv)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.