title: Lift value calculation
body: <p>I have a (symmetric) adjacency matrix, which has been created based on the co-occurence of names (e.g.: Greg, Mary, Sam, Tom) in newspaper articles (e.g.: a,b,c,d). See below.  </p>
  
  <p>How to <strong>calculate the lift value</strong> for the non-zero matrix elements (<a href="http://en.wikipedia.org/wiki/Lift_(data_mining)" rel="nofollow">http://en.wikipedia.org/wiki/Lift_(data_mining)</a>)? </p>
  
  <p>I would be interested in an efficient implementation, which could also be used for very large matrices (e.g. a million non-zero elements).</p>
  
  <p>I appreciate any help.</p>
  
  <pre><code># Load package
  library(Matrix)
  
  # Data
  A &lt;- new("dgTMatrix"
      , i = c(2L, 2L, 2L, 0L, 3L, 3L, 3L, 1L, 1L)
      , j = c(0L, 1L, 2L, 0L, 1L, 2L, 3L, 1L, 3L)
      , Dim = c(4L, 4L)
      , Dimnames = list(c("Greg", "Mary", "Sam", "Tom"), c("a", "b", "c", "d"))
      , x = c(1, 1, 1, 1, 1, 1, 1, 1, 1)
      , factors = list()
  )
  
  # &gt; A
  # 4 x 4 sparse Matrix of class "dgTMatrix"
  #      a b c d
  # Greg 1 . . .
  # Mary . 1 . 1
  # Sam  1 1 1 .
  # Tom  . 1 1 1
  
  # One mode projection of the data 
  # (i.e. final adjacency matrix, which is the basis for the lift value calculation)
  A.final &lt;- tcrossprod(A)
  
  # &gt; A.final
  # 4 x 4 sparse Matrix of class "dsCMatrix"
  #      Greg Mary Sam Tom
  # Greg    1    .   1   .
  # Mary    .    2   1   2
  # Sam     1    1   3   2
  # Tom     .    2   2   3
  </code></pre>