Description Usage Arguments Value Examples
This function takes in an outcome and covariates, and uses cross validation to find the best lambda0 value.
1 2 3 |
Y |
The outcome to be analyzed |
X |
An n by p matrix of covariates |
lambda1 |
Prior parameter for the slab component of the prior |
lambda0seq |
Sequence of lambda0 values to consider |
groups |
A vector of length p denoting which group each covariate is in |
a |
First hyperparameter for the beta prior denoting the prior probability of being in the slab |
b |
Second hyperparameter for the beta prior denoting the prior probability of being in the slab |
nFolds |
The number of folds to run cross validation on |
M |
Positive number less than p indicating how often to update theta and sigma. There is no need to change this unless trying to optimize computation time |
forceGroups |
A vector containing the indices of any groups you wish to automatically include in the model and not penalize |
A list of values containing the lambda0 that minimizes the cross-validated error, the vector of cross validated errors for each lambda0 in the sequence, and the lambda0 sequence looked at
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Here we generate 200 samples from 100 covariates
n = 200
G = 100
x = mvtnorm::rmvnorm(n, sigma=diag(G))
X = matrix(NA, nrow=n, ncol=G*2)
for (g in 1 : G) {
X[,2*(g-1) + 1] = x[,g]
X[,2*g] = x[,g]^2
}
Y = x[,1] + x[,2] + 0.6*x[,2]^2 + rnorm(n, sd=1)
## Now find the best lambda0 using cross-validation
modSSGLcv = SSGLcv(Y=Y, X=X, lambda1=.1,
lambda0seq = seq(1,100, by=2),
groups = rep(1:G, each=2),
nFolds = 5)
modSSGL = SSGL(Y=Y, X=X, lambda1=.1, lambda0=modSSGLcv$lambda0,
groups = rep(1:G, each=2))
modSSGL
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.