-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
94 lines (74 loc) · 2.29 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
93
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# wdm
[![R-CMD-check](https://github.com/tnagler/wdm-r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tnagler/wdm-r/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/wdm)](https://cran.r-project.org/package=wdm)
![CRAN downloads](http://cranlogs.r-pkg.org/badges/wdm)
R interface to the [wdm](https://github.com/tnagler/wdm) C++ library, which
provides efficient implementations of weighted dependence measures and related
independence tests:
* Pearsons's rho
* Spearmans's rho
* Kendall's tau
* Blomqvist's beta
* Hoeffding's D
All measures are computed in *O(n* log *n)* time, where *n* is the number of
observations.
For a detailed description of the functionality, see the
[API documentation](https://tnagler.github.io/wdm-r/).
### Installation
- the stable release from CRAN:
``` r
install.packages("wdm")
```
- the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
install_submodule_git <- function(x, ...) {
install_dir <- tempfile()
system(paste("git clone --recursive", shQuote(x), shQuote(install_dir)))
devtools::install(install_dir, ...)
}
install_submodule_git("https://github.com/tnagler/wdm-r")
```
### Cloning
This repo contains [wdm](https://github.com/tnagler/wdm) as a submodule. For
a full clone use
``` shell
git clone --recurse-submodules <repo-address>
```
### Examples
```{r}
library(wdm)
```
##### Dependence between two vectors
``` {r}
x <- rnorm(100)
y <- rpois(100, 1) # all but Hoeffding's D can handle ties
w <- runif(100)
wdm(x, y, method = "kendall") # unweighted
wdm(x, y, method = "kendall", weights = w) # weighted
```
##### Dependence in a matrix
``` {r}
x <- matrix(rnorm(100 * 3), 100, 3)
wdm(x, method = "spearman") # unweighted
wdm(x, method = "spearman", weights = w) # weighted
```
##### Independence test
``` {r}
x <- rnorm(100)
y <- rpois(100, 1) # all but Hoeffding's D can handle ties
w <- runif(100)
indep_test(x, y, method = "kendall") # unweighted
indep_test(x, y, method = "kendall", weights = w) # weighted
```