This package provides functions for fitting split generalized linear models.
You can install the stable version on R CRAN.
install.packages("SplitGLM", dependencies = TRUE)
You can install the development version from GitHub
library(devtools)
::install_github("AnthonyChristidis/SplitGLM") devtools
# Required Libraries
library(mvnfast)
# Sigmoid function
<- function(t){
sigmoid return(exp(t)/(1+exp(t)))
}
# Data simulation
set.seed(1)
<- 50
n <- 2000
N <- 1000
p <- c(abs(runif(p, 0, 1/2))*(-1)^rbinom(p, 1, 0.3))
beta.active # Parameters
<- 100
p.active <- c(beta.active[1:p.active], rep(0, p-p.active))
beta <- matrix(0, p, p)
Sigma 1:p.active, 1:p.active] <- 0.5
Sigma[diag(Sigma) <- 1
# Train data
<- rmvn(n, mu = rep(0, p), sigma = Sigma)
x.train <- sigmoid(x.train %*% beta)
prob.train <- rbinom(n, 1, prob.train)
y.train
# Test data
<- rmvn(N, mu = rep(0, p), sigma = Sigma)
x.test <- sigmoid(x.test %*% beta + offset)
prob.test <- rbinom(N, 1, prob.test)
y.test mean(y.test)
<- y.test==0
sp.sen.par
# SplitGLM - CV (Multiple Groups)
<- cv.SplitGLM(x.train, y.train,
split.out type="Logistic",
G=10, include_intercept=TRUE,
alpha_s=3/4,
n_lambda_sparsity=100, n_lambda_diversity=100,
tolerance=1e-3, max_iter=1e3,
n_folds=5,
active_set=FALSE,
full_diversity=TRUE,
n_threads=1)
# Coefficients
<- coef(split.out)
split.coef
# Predictions
<- predict(split.out, newx=x.test, type="prob")
split.prob
# Plot of output
plot(prob.test, split.prob, pch=20)
abline(h=0.5,v=0.5)
# MR
<- predict(split.out, newx=x.test, type="class")
split.class mean(abs(y.test-split.class))
This package is free and open source software, licensed under GPL (>= 2).