## Overview

The LDATS package provides functionality for analyzing time series of high-dimensional data using a two-stage approach comprised of Latent Dirichlet Allocation (LDA) and Bayesian time series (TS) analyses.

For a full description of the math underlying the LDATS package, see the technical document.

## Status: Stable Version Available, Continuing Development

A stable version of LDATS is available on CRAN, but the package is actively being developed by the Weecology Team. The API is well defined at this point and should not change substantially.

## Installation

You can install the stable version of LDATS from CRAN with:

To obtain the current development version of LDATS from GitHub, install the devtools package and then use it to install LDATS:

install.packages("devtools")
devtools::install_github("weecology/LDATS")

## Usage

Here is an example of a full LDA-TS analysis using the Portal rodent data:

library(LDATS)
data(rodents)
r_LDATS <- LDA_TS(rodents, topics = 2:5, nseeds = 2, formulas = ~1,
nchangepoints = 0:1, timename = "newmoon")

Which conducts two replicates (nseeds) for each of two to five topics in an LDA model using the document term table, selects the best (AIC) of those, then conducts two time series models on it (an intercept-only model under 0 and 1 changepoints), then selects the best (AIC) of the time series, and packages all the models together. This uses the document term table to weight the samples by their sizes (number of words) and instructs the function to use the column named "newmoon" in the document covariates table as the time variable.

The resulting object is of class LDA_TS, which has a few basic routines available:

print(r_LDATS)

prints the selected LDA and TS models and

plot(r_LDATS)

produces a 4-panel figure of them a la Figure 1 from Christensen et al. 2018.