-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
92 lines (54 loc) · 2.47 KB
/
README.Rmd
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
fig.path = "man/figures/README-",
out.width = "100%",
tidy = TRUE,
tidy.opts = list(width.cutoff = 70)
)
```
# OSCAR models with R
Optimal Subset CArdinality Regression (OSCAR) models with R
# Citation
Halkola et al. OSCAR: Optimal subset cardinality regression using the L0-pseudonorm, with applications to modelling prostate cancer biomarkers.
# CRAN
The ```oscar``` package is available from the Central R Archive Network (CRAN), and can be installed with:
```{r cran, eval = FALSE, warning = FALSE, message = FALSE}
install.packages("oscar")
```
Canonical direct CRAN link:
https://CRAN.R-project.org/package=oscar
# GitHub installation
While the CRAN installation may be most convenient for user installation, the latest modifications and package release come through GitHub. Therefore there may be a slight lag in delivering the latest release to CRAN, and the user may wish to install the latest GitHub-version by:
```{r github, eval = FALSE, warning = FALSE, message = FALSE}
install.packages("devtools")
devtools::install_github("Syksy/oscar")
```
# Brief examples
Below are brief examples on ```oscar``` usage. More elaborate examples can be found from within the package in the examples vignette.
```{r example, eval = FALSE, warning = FALSE, message = FALSE, tidy.opts=list(width.cutoff=70)}
# Load the oscar-package
library(oscar)
# Load example dataset (consists of ex_X, ex_Y, ex_K and ex_c) for Cox regression
data(ex)
# Test run, notice this uses all the data! Smaller test would be feasible
fit <- oscar::oscar(x=ex_X, y=ex_Y, k=ex_K, w=ex_c, family="cox")
# Show model results and other attributes
fit
# Visualize fit as a function of allowed kits
oscar::oscar.visu(fit, y=c("target", "goodness"))
# Example of cross-validation based k-selection
cv <- oscar::oscar.cv(fit, fold=5, seed=123) # 5-fold cross-validation, with fixed seed
# Visualize the cross-validation curve (highest point in c-index in optimal generalizable k-value)
oscar::oscar.cv.visu(cv)
# Naive example using events in logistic regression (placeholder PoC, end-point ought to be time-dependent rather)
fit2 <- oscar::oscar(x=ex_X, y=ex_Y[,2], k=ex_K, w=ex_c, family="logistic")
oscar::oscar.visu(fit2, y=c("target", "goodness"))
# Example swiss fertility data
data(swiss)
fit_mse <- oscar::oscar(x=swiss[,-1], y=swiss[,1], family="gaussian")
fit_mse
```