SplitGLM {SplitGLM}R Documentation

Split Generalized Linear Model

Description

SplitGLM performs computes the coefficients for split generalized linear models.

Usage

SplitGLM(
  x,
  y,
  glm_type = "Linear",
  G = 10,
  include_intercept = TRUE,
  alpha_s = 3/4,
  alpha_d = 1,
  lambda_sparsity,
  lambda_diversity,
  tolerance = 0.001,
  max_iter = 1e+05,
  active_set = FALSE
)

Arguments

x

Design matrix.

y

Response vector.

glm_type

Description of the error distribution and link function to be used for the model. Must be one of "Linear", "Logistic", "Gamma" or "Poisson".

G

Number of groups into which the variables are split. Can have more than one value.

include_intercept

Boolean variable to determine if there is intercept (default is TRUE) or not.

alpha_s

Elastic net mixing parmeter. Default is 3/4.

alpha_d

Mixing parameter for diversity penalty. Default is 1.

lambda_sparsity

Sparsity tuning parameter value.

lambda_diversity

Diversity tuning parameter value.

tolerance

Convergence criteria for the coefficients. Default is 1e-3.

max_iter

Maximum number of iterations in the algorithm. Default is 1e5.

active_set

Active set convergence for the algorithm. Default is FALSE.

Value

An object of class SplitGLM.

Author(s)

Anthony-Alexander Christidis, anthony.christidis@stat.ubc.ca

See Also

coef.SplitGLM, predict.SplitGLM

Examples


# Data simulation
set.seed(1)
n <- 50
N <- 2000
p <- 1000
beta.active <- c(abs(runif(p, 0, 1/2))*(-1)^rbinom(p, 1, 0.3))
# Parameters
p.active <- 100
beta <- c(beta.active[1:p.active], rep(0, p-p.active))
Sigma <- matrix(0, p, p)
Sigma[1:p.active, 1:p.active] <- 0.5
diag(Sigma) <- 1

# Train data
x.train <- mvnfast::rmvn(n, mu = rep(0, p), sigma = Sigma) 
prob.train <- exp(x.train %*% beta)/
              (1+exp(x.train %*% beta))
y.train <- rbinom(n, 1, prob.train)
mean(y.train)
# Test data
x.test <- mvnfast::rmvn(N, mu = rep(0, p), sigma = Sigma)
prob.test <- exp(x.test %*% beta)/
             (1+exp(x.test %*% beta))
y.test <- rbinom(N, 1, prob.test)
mean(y.test)

# SplitGLM - Multiple Groups
split.out <- SplitGLM(x.train, y.train,
                      glm_type="Logistic",
                      G=10, include_intercept=TRUE,
                      alpha_s=3/4, alpha_d=1,
                      lambda_sparsity=1, lambda_diversity=1,
                      tolerance=1e-3, max_iter=1e3,
                      active_set=FALSE)
split.coef <- coef(split.out)
# Predictions
split.prob <- predict(split.out, newx=x.test, type="prob", group_index=NULL)
split.class <- predict(split.out, newx=x.test, type="class", group_index=NULL)
plot(prob.test, split.prob, pch=20)
abline(h=0.5,v=0.5)
mean((prob.test-split.prob)^2)
mean(abs(y.test-split.class))




[Package SplitGLM version 1.0.5 Index]