R/MRI.R

Defines functions MRI

MRI <- function(U, V) {
  TA <- table(U, V, useNA = "ifany")
  m <- sum(TA[is.na(rownames(TA)) == FALSE, is.na(colnames(TA)) == FALSE])

  (choose(m, 2) +
      sum(TA[is.na(rownames(TA)) == FALSE, is.na(colnames(TA)) == FALSE]^2) -
      1/2*(sum(rowSums(TA[is.na(rownames(TA)) == FALSE, is.na(colnames(TA)) == FALSE])^2) + sum(colSums(TA[is.na(rownames(TA)) == FALSE, is.na(colnames(TA)) == FALSE])^2)))/choose(sum(TA), 2)
}

Try the nem package in your browser

Any scripts or data that you put into this service are public.

nem documentation built on April 23, 2021, 3 p.m.