BNNsel {BNN} | R Documentation |
Perform variable selection and calculate posterior probabilities for the classes of linear and nonlinear of models.
BNNsel(X,Y,train_num,hid_num=3,lambda=0.025,total_iteration=1000000 ,popN=20,nCPUs=20)
X |
a nxp input data matrix. |
Y |
response vector. |
train_num |
Number of training samples, should be smaller or equal to n. The default setting is the first 80% rows of the input samples. |
hid_num |
Number of hidden units. The default setting is 3. |
lambda |
The prior probability for each connection of the neural network being selected for the final model. The default setting is 0.025. |
total_iteration |
Number of iterations, recommend to be larger than or equal to 10,000. The default setting is 1000,000. |
popN |
Number of Markov Chains in a parallel run, should be larger than or equal to 3. The default setting is 20. |
nCPUs |
Number of CPUs to be used in the simulation. The default setting is 20. |
A list of five elements:
net |
Marginal inclusion probability of each connection of the neural network. |
prob |
Posterior probability of the class of linear models. |
mar |
Marginal inclusion probability of each input variable, which can be used for variable selection based on a multiple-hypothesis test or the median probability model criterion. |
fit |
Fitted value for the response vector of training data. |
pred |
Predicted value for the response vector of testing data. |
Bochao Jia and Faming Liang
Liang, F., Li, Q., and Zhou, L. (2017). Bayesian Neural Networks for Selection of Drug Sensitive Genes. Journal of the American Statistical Association.
## simulate data ## library(BNN) library(mvtnorm) n <- 200 p <- 50 X <- rmvnorm(n, mean = rep(1,p), sigma = diag(rep(1,p))) eps <- rnorm(n,0,0.5) Y <- X[,1]*X[,2]+3*sin(X[,3])-2*cos(X[,4])+X[,5]^2+eps ### fit BNN model ### BNNsel(X,Y,hid_num = 3,lambda=0.025,total_iteration = 100000, popN = 10,nCPUs = 10)