-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
70 lines (57 loc) · 1.45 KB
/
README.Rmd
File metadata and controls
70 lines (57 loc) · 1.45 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ilasso
<!-- badges: start -->
<!-- badges: end -->
The goal of ilasso is to help identifying interactions via hierarchical lasso regularisation using a two-step procedure.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("abuchardt/ilasso")
```
## Example
This is a basic example on simulated data:
```{r example}
library(ilasso)
# Gaussian
p <- 200
n <- 100
nz <- dplyr::arrange(expand.grid(a = 1:p, b = 1:p), a)
X <- matrix(sample(c(TRUE, FALSE), n * p, replace = TRUE), nrow = n, ncol = p)
ind <- t(combn(ncol(X),2))
out <- apply(ind, 1, function(x) X[,x[1]] * X[,x[2]])
XX <- cbind(X, out)
beta <- c(3,3, rep(0, ncol(X)-2))
beta12 <- c(3, rep(0, choose(p, 2)-1))
y <- XX %*% c(beta,beta12) + rnorm(n)
```
Run step 1
```{r step1}
# Step 1
fit1 <- ilasso(x = X, y = y, step = "first")
me1 <- fit1$maineffects1
print(fit1)
```
Run step 2 under strong hierarchy (default)
```{r step2}
# Step 2
fit2 <- ilasso(x = X, y = y, step = "second", maineffects1 = me1)
print(fit2)
```
Run both steps under strong hierarchy (default)
```{r both}
# Both steps
fit12 <- ilasso(x = X, y = y, step = "both")
print(fit2)
```