nnGarrote: Non-negative Garrote Estimator

Description Usage Arguments Value Author(s) See Also Examples

View source: R/nnGarrote.R

Description

nnGarrote computes the non-negative garrote estimator.

Usage

1
2
3
4
5
6
7
8
9
nnGarrote(
  x,
  y,
  intercept = TRUE,
  initial.model = c("LS", "glmnet")[1],
  lambda.nng = NULL,
  lambda.initial = NULL,
  alpha = 0
)

Arguments

x

Design matrix.

y

Response vector.

intercept

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

initial.model

Model used for the groups. Must be one of "LS" (default) or "glmnet".

lambda.nng

Shinkage parameter for the non-negative garrote. If NULL(default), it will be computed based on data.

lambda.initial

The shinkrage parameter for the "glmnet" regularization. If NULL (default), optimal value is chosen by cross-validation.

alpha

Elastic net mixing parameter for initial estimate. Should be between 0 (default) and 1.

Value

An object of class nnGarrote.

Author(s)

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

See Also

coef.nnGarrote, predict.nnGarrote

Examples

 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
# Setting the parameters
p <- 500
n <- 100
n.test <- 5000
sparsity <- 0.15
rho <- 0.5
SNR <- 3
set.seed(0)
# Generating the coefficient
p.active <- floor(p*sparsity)
a <- 4*log(n)/sqrt(n)
neg.prob <- 0.2
nonzero.betas <- (-1)^(rbinom(p.active, 1, neg.prob))*(a + abs(rnorm(p.active)))
true.beta <- c(nonzero.betas, rep(0, p-p.active))
# Two groups correlation structure
Sigma.rho <- matrix(0, p, p)
Sigma.rho[1:p.active, 1:p.active] <- rho
diag(Sigma.rho) <- 1
sigma.epsilon <- as.numeric(sqrt((t(true.beta) %*% Sigma.rho %*% true.beta)/SNR))

# Simulate some data
library(mvnfast)
x.train <- mvnfast::rmvn(n, mu=rep(0,p), sigma=Sigma.rho)
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.rho)
y.test <- 1 + x.test %*% true.beta + rnorm(n.test, sd=sigma.epsilon)

# Applying the NNG with Ridge as an initial estimator
nng.out <- nnGarrote(x.train, y.train, intercept=TRUE,
                     initial.model=c("LS", "glmnet")[2],
                     lambda.nng=NULL, lambda.initial=NULL, alpha=0)
nng.predictions <- predict(nng.out, newx=x.test)
nng.coef <- coef(nng.out)

nnGarrote documentation built on Oct. 7, 2021, 9:06 a.m.