IterativeHardThresholding
is part of the HADES.
IterativeHardThresholding
is an R
package
for performing L_0-based regressions using Cyclops
library(Cyclops)
library(IterativeHardThresholding)
library(survival)
## data dimension
<- 20 # number of covariates
p <- 300 # sample size
n
## tuning parameters
<- log(n) # BAR penalty (BIC)
lambda <- 0.1 # initial ridge penalty
xi
## Cox model parameters
<- c(1, 0.1, 0, -1, 1, rep(0, p - 5))
true.beta
## simulate data from an exponential model
<- matrix(rnorm(p * n, mean = 0, sd = 1), ncol = p)
x <- rweibull(n, shape = 1, scale = exp(-x%*%true.beta))
ti <- runif(n, 0, 10) # Controls censoring
ui <- rweibull(n, shape = 1, scale = ui * exp(-x%*%true.beta))
ci <- pmin(ti, ci)
survtime <- ti == survtime; mean(delta)
delta
<- createCyclopsData(Surv(survtime, delta) ~ x, modelType = "cox")
cyclopsData <- createIhtPrior(K = 3, penalty = "bic")
ihtPrior
<- fitCyclopsModel(cyclopsData,
cyclopsFit prior = ihtPrior)
coef(cyclopsFit)
library(Cyclops)
library(IterativeHardThresholding)
## data dimension
<- 20 # number of covariates
p <- 300 # sample size
n
## tuning parameters
<- log(n) # BAR penalty (BIC)
lambda <- 0.1 # initial ridge penalty
xi
## logistic model parameters
<- 0.2 # intercept
itcpt <- c(1, 0.3, 0, -1, 1, rep(0, p - 5))
true.beta
## simulate data from logistic model
<- matrix(rnorm(p * n, mean = 0, sd = 1), ncol = p)
x <- rbinom(n, 1, 1 / (1 + exp(-itcpt - x%*%true.beta)))
y
# fit BAR model
<- createCyclopsData(y ~ x, modelType = "lr")
cyclopsData <- createIhtPrior(K = 3, penalty = "bic", exclude = c("(Intercept)"))
ihtPrior
<- fitCyclopsModel(cyclopsData,
cyclopsFit prior = ihtPrior)
coef(cyclopsFit)
Requires R
(version 3.2.0 or higher). Installation on
Windows requires RTools
(devtools >= 1.12
required for RTools34, otherwise
RTools33 works fine).
Cyclops
IterativeHardThresholding
:install.packages("devtools")
library(devtools)
install_github("ohdsi/Cyclops")
install_github("ohdsi/IterativeHardThresholding")
library(IterativeHardThresholding)
<- createCyclopsData(formula, modelType = "modelType") ## TODO: Update
cyclopsData <- createIhtPrior(K = 5, penalty = "bic")
ihtPrior <- fitCyclopsModel(cyclopsData, prior = ihtPrior)
cyclopsFit coef(cyclopsFit) #Extract coefficients
IterativeHardThresholding
is licensed under Apache
License 2.0.
IterativeHardThresholding
is being developed in R
Studio.