bstewart / stm

An R Package for the Structural Topic Model
Other
395 stars 98 forks source link

DMR topic model? #7

Closed lieove closed 8 years ago

lieove commented 9 years ago

it's wonderful. And I try to use DMR topic model, but i find there is something wrong with the parameter init.type of manyTopics function. like this: Error in match.arg(init.type) : 'arg' should be one of "LDA", "Random", "Spectral" I install the latest version 1.0.12. Why? Hope you can help me. Thanks!

bstewart commented 9 years ago

I'm not really sure. I'll take a look.

In the interim- I'd recommend using the searchK() function instead. Its a bit more robust and will probably do what you need it to do. Also take a look at the new vignette here: https://github.com/bstewart/stm/blob/master/inst/doc/stmVignette.pdf?raw=true

bstewart commented 9 years ago

Also could you post a reproducible example? It would be quite helpful in identifying the problem. You can use the help file for manyTopics to construct one with the data in the package.

lieove commented 9 years ago

As the help file said, the init.type of selectModel and manyTopics must be either Latent Dirichlet Allocation (LDA), Dirichlet Multinomial Regression Topic Model (DMR), a random initialization\ or a previous STM object. I follow the example, and i want to use DMR . so i add the parameter init.type='DMR' in the manyTopics and selectModel . Both of them can't work. And i found init.type shoule be one of "LDA", "Random", "Spectral", but not 'DMR'. The example is as follows. ########### library(stm) temp<-textProcessor(documents=gadarian$open.ended.response,metadata=gadarian) meta<-temp$meta vocab<-temp$vocab docs<-temp$documents out <- prepDocuments(docs, vocab, meta) docs<-out$documents vocab<-out$vocab meta <-out$meta set.seed(02138) storage<-manyTopics(docs,vocab,K=3:4, prevalence=~treatment + s(pid_rep),data=meta, runs=10, init.type='DMR') ############## And when change init.type='LDA', it works. So i'm confuse about it and it not match as the help file.