# coef.cv.CPGLIB: Coefficients for cv.CPGLIB Object In CPGLIB: Competing Proximal Gradients Library

## Description

`coef.cv.CPGLIB` returns the coefficients for a cv.CPGLIB object.

## Usage

 ```1 2``` ```## S3 method for class 'cv.CPGLIB' coef(object, groups = NULL, ensemble_average = FALSE, ...) ```

## Arguments

 `object` An object of class cv.CPGLIB. `groups` The groups in the ensemble for the coefficients. Default is all of the groups in the ensemble. `ensemble_average` Option to return the average of the coefficients over all the groups in the ensemble. Default is FALSE. `...` Additional arguments for compatibility.

## Value

The coefficients for the cv.CPGLIB object. Default is FALSE.

## Author(s)

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

`cv.cpg`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37``` ```# Data simulation set.seed(1) n <- 50 N <- 2000 p <- 300 beta.active <- c(abs(runif(p, 0, 1/2))*(-1)^rbinom(p, 1, 0.3)) # Parameters p.active <- 150 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) mean(y.test) # CV CPGLIB - Multiple Groups cpg.out <- cv.cpg(x.train, y.train, glm_type = "Logistic", G = 5, include_intercept = TRUE, alpha_s = 3/4, alpha_d = 1, n_lambda_sparsity = 100, n_lambda_diversity = 100, balanced_cycling = TRUE, tolerance = 1e-5, max_iter = 1e5) cpg.coef <- coef(cpg.out) # Coefficients for each group cpg.coef <- coef(cpg.out, ensemble_average = FALSE) ```