This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Modifies the code in | |
# github thread: https://gist.github.com/ratsgo/c25deb6d79f3ab8b0b050af751fbbdb8#file-plsa-r-L78 | |
# to speed it up by introducing vectorisation alternatives to nested for loops | |
# and by avoiding cumbersome string lookups | |
# assuming this is based on Hofmann (2001) https://doi.org/10.1023/A:1007617005950, p. 182 eqns 6, 11 and 12 but re-casted for parametrization as in eq. 5 | |
# prepare corpus | |
corpus <- matrix(c(1,2,0,0,0,0, |