Giter Site home page Giter Site logo

stm's Introduction

##stm: An R Package for the Structural Topic Model

Website: www.structuraltopicmodel.com

Vignette: Here

Authors: Molly Roberts, Brandon Stewart and Dustin Tingley

Please email all comments/questions to bstewart [AT] fas.harvard.edu

###Summary

This repository contains an early release for the stm package for R. It implements variational EM algorithms for estimating topic models with covariates in a framework we call the Structural Topic Model (stm). Future releases will be available on CRAN but we are using the repository here to provide a soft release.

The package currently includes functionality to:

  • ingest and manipulate text data
  • estimate Structural Topic Models
  • calculate covariate effects on latent topics with uncertainty
  • estimate a graph of topic correlations
  • create all the plots used in our various papers

###Other Resources

Have a large text corpus or need a language we don't provide support for? See our sister project txtorg

Papers on the Structural Topic Model:

  • Roberts, Stewart and Airoldi. "Structural Topic Models"
  • Roberts, Stewart, Tingley, and Airoldi. "The Structural Topic Model and Applied Social Science." Advances in Neural Information Processing Systems Workshop on Topic Models: Computation, Application, and Evaluation. 2013. Copy available here
  • Roberts, Stewart, Tingley, Lucas, Leder-Luis, Gadarian, Albertson, and Rand. "Structural topic models for open-ended survey responses." American Journal of Political Science. Forthcoming. Copy available here
  • Lucas, Nielsen, Roberts, Stewart, Storer, and Tingley. "Computer assisted text analysis for comparative politics." Copy available here

Installation Instructions

Assuming you already have R installed (if not see http://www.r-project.org/), the easiest approach is to use the devtools package to install directly from github. First you have to install devtools using the following code. Note that you only have to do this once

if(!require(devtools)) install.packages("devtools")

Then you can load the package and use the function install_github

library(devtools)
install_github("bstewart/stm",dependencies=TRUE)

Note that this will install all the packages suggested and required to run our package. It may take a few minutes the first time, but this only needs to be done on the first use. In the future you can update to the most recent development version using the same code.

You can also grab the binaries or source files for the latest release here: (https://github.com/bstewart/stm/releases). Then use install.packages with repos=NULL so that

install.packages(filepath, repos = NULL)

Getting Started

See the vignette for several example analyses. The main function to estimate the model is stm() but there are a host of other useful functions. If you have your documents already converted to term-document matrices you can ingest them using readCorpus(). If you just have raw texts you will want to start with textProcessor().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.