coef.ProxGrad: Coefficients for ProxGrad Object

View source: R/ProxGrad_Coefficient_Functions.R

coef.ProxGradR Documentation

Coefficients for ProxGrad Object

Description

coef.ProxGrad returns the coefficients for a ProxGrad object.

Usage

## S3 method for class 'ProxGrad'
coef(object, ...)

Arguments

object

An object of class ProxGrad.

...

Additional arguments for compatibility.

Value

The coefficients for the ProxGrad object.

Author(s)

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

See Also

ProxGrad

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)
# 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)

# ProxGrad - Single Group
proxgrad.out <- ProxGrad(x.train, y.train,
                         glm_type = "Logistic",
                         include_intercept = TRUE,
                         alpha_s = 3/4,
                         lambda_sparsity = 0.01, 
                         tolerance = 1e-5, max_iter = 1e5)

# Coefficients
coef(proxgrad.out)




CPGLIB documentation built on Nov. 22, 2022, 5:08 p.m.