The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
BrokenAdaptiveRidge
is an R
package for
performing L_0-based regressions using Cyclops
library(Cyclops)
library(BrokenAdaptiveRidge)
## data dimension
<- 30 # number of covariates
p <- 200 # sample size
n
## logistic model parameters
<- 0.2 # intercept
itcpt <- c(1, 0, 0, -1, 1, rep(0, p - 5))
true.beta
## simulate data from logistic model
set.seed(100)
<- matrix(rnorm(p * n, mean = 0, sd = 1), ncol = p)
x <- ifelse(abs(x) > 1., 1, 0)
x <- rbinom(n, 1, 1 / (1 + exp(-itcpt - x%*%true.beta)))
y
# fit BAR model
<- createCyclopsData(y ~ x, modelType = "lr")
cyclopsData <- createBarPrior(penalty = 0.1, exclude = c("(Intercept)"),
barPrior initialRidgeVariance = 1)
<- fitCyclopsModel(cyclopsData,
cyclopsFit prior = barPrior)
<- coef(cyclopsFit)
fit1
# fit BAR using sparse-represented covariates
<- apply(x, 1, function(x) which(x != 0))
tmp
<- data.frame(rowId = 1:n, y = y)
y.df <- data.frame(rowId = rep(1:n, lengths(tmp)), covariateId = unlist(tmp), covariateValue = 1)
x.df
<- convertToCyclopsData(outcomes = y.df, covariates = x.df, modelType = "lr")
cyclopsData <- createFastBarPrior(penalty = 0.1, exclude = c("(Intercept)"),
barPrior initialRidgeVariance = 1)
<- coef(cyclopsFit)
fit2
# fit BAR using cyclic algorithm
<- createCyclopsData(y ~ x, modelType = "lr")
cyclopsData <- createFastBarPrior(penalty = 0.1, exclude = c("(Intercept)"),
barPrior initialRidgeVariance = 1)
<- fitCyclopsModel(cyclopsData,
cyclopsFit prior = barPrior)
<- coef(cyclopsFit)
fit3
fit1
fit2 fit3
Requires R
(version 3.2.0 or higher).
Cyclops
BrokenAdaptiveRidge
:install.packages("devtools")
library(devtools)
install.packages("ohdsi/Cyclops")
install_github("ohdsi/BrokenAdaptiveRidge")
library(BrokenAdaptiveRidge)
<- createCyclopsData(formula, modelType = "modelType") ## TODO: Update
cyclopsData <- createBarPrior(penalty = lambda / 2, initialRidgeVariance = 2 / xi)
barPrior <- fitCyclopsModel(cyclopsData, prior = barPrior)
cyclopsFit coef(cyclopsFit) #Extract coefficients
BrokenAdaptiveRidge
is licensed under Apache License
2.0.
BrokenAdaptiveRidge
is being developed in R Studio.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.