This package provides functions to generate ensembles of generalizedlinear models using a projected subset gradient descent algorithm.
You can install thestable version onR CRAN.
install.packages("PSGD",dependencies =TRUE)You can install thedevelopment version fromGitHub.
library(devtools)devtools::install_github("AnthonyChristidis/PSGD")# Required Librarieslibrary(mvnfast)# Setting the parametersp<-100n<-40n.test<-2000sparsity<-0.2rho<-0.5SNR<-3set.seed(0)# Generating the coefficientp.active<-floor(p*sparsity)a<-4*log(n)/sqrt(n)neg.prob<-0.2nonzero.betas<- (-1)^(rbinom(p.active,1, neg.prob))*(a+abs(rnorm(p.active)))# Correlation structureSigma<-matrix(0, p, p)Sigma[1:p.active,1:p.active]<- rhodiag(Sigma)<-1true.beta<-c(nonzero.betas,rep(0 , p- p.active))# Computing the noise parameter for target SNRsigma.epsilon<-as.numeric(sqrt((t(true.beta)%*% Sigma%*% true.beta)/SNR))# Simulate some dataset.seed(1)x.train<- mvnfast::rmvn(n,mu=rep(0,p),sigma=Sigma)y.train<-1+ x.train%*% true.beta+rnorm(n=n,mean=0,sd=sigma.epsilon)x.test<- mvnfast::rmvn(n.test,mu=rep(0,p),sigma=Sigma)y.test<-1+ x.test%*% true.beta+rnorm(n.test,sd=sigma.epsilon)# CV PSGD Ensembleoutput<-cv.PSGD(x = x.train,y = y.train,n_models =5,model_type =c("Linear","Logistic")[1],include_intercept =TRUE,split =c(2,3),size =c(10,15),max_iter =20,cycling_iter =0,n_folds =5,n_threads =1)psgd.coef<-coef(output,group_index =1:output$n_models)psgd.predictions<-predict(output,newx = x.test,group_index =1:output$n_models)mean((y.test- psgd.predictions)^2)/sigma.epsilon^2This package is free and open source software, licensed under GPL(>= 2).