-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
60 lines (42 loc) · 2.96 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
---
title: "ess: Efficient Stepwise Selection in Decomposable Models"
output:
github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
<!-- badges: start -->
[![R build status](https://github.com/mlindsk/ess/workflows/R-CMD-check/badge.svg)](https://github.com/mlindsk/ess/actions)
[![](https://www.r-pkg.org/badges/version/ess?color=green)](https://cran.r-project.org/package=ess)
<!-- badges: end -->
## About ess
The **ess** package is an **R** implementation of the algorithm presented in [this paper](https://arxiv.org/abs/1301.2267) and later corrected slightly [in this paper](https://doi.org/10.1109/ictai.2004.100). The ESS algorithm is used for model selection in discrete decomposable graphical models. It is fast compared to other model selection procedures in **R**, especially when data is high-dimensional.
## Decomposable Graphical Models
The class of graphical models is a family of probability distributions for which conditional dependencies can be read off from a graph. If the graph is decomposable, the maximum likelihood estimates of the parameters in the model can be shown to be on exact form. This is what enables ESS to be fast and efficient.
## Installation
You can install the current stable release of the package by using the `devtools` package:
```{r, eval = FALSE}
devtools::install_github("mlindsk/ess", build_vignettes = FALSE)
```
## Getting Started
The main function in **ess** is `fit_graph` which fits a decomposable graph. An object returned from `fit_graph` is a `gengraph` object. `fit_graph` has four types; forward selection (`fwd`), backward selection (`bwd`), tree (`tree`) and a combination of tree and forward (`tfwd`). Using `adj_lst` on an object returned by `fit_graph` gives the adjacency list corresponding to the graph. Similarly one can use `adj_mat` to obtain an adjacency matrix. Finally, the object can be converted to an `igraph` object using the `as_igraph` function.
A neat usecase of **ess** is that of variable selection. Consider the built-in data `derma` (dermatitis) with class variable `ES`. We can fit a graph structure to this data, and inspect the graph to see which variables `ES` directly depends upon:
```{r var_select}
library(ess)
g <- fit_graph(derma)
plot(g, vertex.size = 1)
```
Instead of inspecting the graph (it can be difficult if there are many variables) we can simply extract the neighbors of `ES`
```{r neighbors}
adj <- adj_lst(g)
adj$ES
```
For more information, see the documentation. E.g. type `?fit_graph` in an **R** session.
## See Also
The [molic](https://github.com/mlindsk/molic) package is used for outlier detection in categorical data and is designed to work with `gengraph` objects. One can use **ess** to fit a `gengraph` object, extract the adjacency matrix, conert it to an `igraph` object and use it in connection with belief propagation via the [jti](https://github.com/mlindsk/jti) package.