Joint LDA and Time Series

Functions for top-level LDATS modeling

LDA_TS() conform_LDA_TS_data() check_LDA_TS_inputs()

Run a full set of Latent Dirichlet Allocations and Time Series models

package_LDA_TS()

Package the output of LDA_TS

print(<LDA_TS>)

Print the selected LDA and TS models of LDA_TS object

plot(<LDA_TS>)

Plot the key results from a full LDATS analysis

set_LDA_TS_plot_cols()

Create the list of colors for the LDATS summary plot

Latent Dirichlet Allocation

Functions to extend exisiting LDA functionality

LDA_set() check_LDA_set_inputs()

Run a set of Latent Dirichlet Allocation models

package_LDA_set()

Package the output from LDA_set

logLik(<LDA_VEM>)

Calculate the log likelihood of a VEM LDA model fit

select_LDA()

Select the best LDA model(s) for use in time series

LDA_msg()

Create the model-running-message for an LDA

plot(<LDA_set>)

Plot a set of LDATS LDA models

plot(<LDA_VEM>) LDA_plot_top_panel() LDA_plot_bottom_panel()

Plot the results of an LDATS LDA model

set_LDA_plot_colors()

Prepare the colors to be used in the LDA plots

Time Series

Functions to execute and evaluate the overall TS model with changepoints and regression components

TS() check_TS_inputs()

Conduct a single multinomial Bayesian Time Series analysis

package_TS()

Summarize the Time Series model

logLik(<TS_fit>)

Determine the log likelihood of a Time Series model

print(<TS_fit>)

Print a Time Series model fit

plot(<TS_fit>)

Plot an LDATS TS model

TS_diagnostics_plot() eta_diagnostics_plots() rho_diagnostics_plots()

Plot the diagnostics of the parameters fit in a TS model

trace_plot()

Produce the trace plot panel for the TS diagnostic plot of a parameter

ecdf_plot()

Produce the posterior distribution ECDF panel for the TS diagnostic plot of a parameter

posterior_plot()

Produce the posterior distribution histogram panel for the TS diagnostic plot of a parameter

autocorr_plot()

Produce the autocorrelation panel for the TS diagnostic plot of a parameter

set_TS_summary_plot_cols()

Create the list of colors for the TS summary plot

TS_summary_plot() pred_gamma_TS_plot() rho_hist()

Create the summary plot for a TS fit to an LDA model

rho_lines()

Add change point location lines to the time series plot

set_rho_hist_colors()

Prepare the colors to be used in the change point histogram

set_gamma_colors()

Prepare the colors to be used in the gamma time series

summarize_etas() measure_eta_vcov()

Summarize the regressor (eta) distributions

summarize_rhos() measure_rho_vcov()

Summarize the rho distributions

est_regressors()

Estimate the distribution of regressors, unconditional on the change point locations

est_changepoints()

Use ptMCMC to estimate the distribution of change point locations

prep_pbar() update_pbar()

Initialize and tick through the progress bar

Multinomial Time Series modeling

Functions to fit the multinomial time series models making up an overall TS model

multinom_TS() check_multinom_TS_inputs()

Fit a multinomial change point Time Series model

logLik(<multinom_TS_fit>)

Log likelihood of a multinomial TS model

multinom_TS_chunk()

Fit a multinomial Time Series model chunk

prep_chunks()

Prepare the time chunk table for a multinomial change point Time Series model

package_chunk_fits()

Package the output of the chunk-level multinomial models into a multinom_TS_fit list

verify_changepoint_locations()

Verify the change points of a multinomial time series model

Parallel tempering Markov Chain Monte Carlo

Functions to execute ptMCMC optimization

prep_ptMCMC_inputs()

Prepare the inputs for the ptMCMC algorithm estimation of change points

prep_ids() update_ids()

Initialize and update the chain ids throughout the ptMCMC algorithm

prep_proposal_dist()

Pre-calculate the change point proposal distribution for the ptMCMC algorithm

prep_saves() update_saves() process_saves()

Prepare and update the data structures to save the ptMCMC output

prep_cpts() update_cpts()

Initialize and update the change point matrix used in the ptMCMC algorithm

prep_temp_sequence()

Prepare the ptMCMC temperature sequence

diagnose_ptMCMC()

Calculate ptMCMC summary diagnostics

count_trips()

Count trips of the ptMCMC particles

swap_chains()

Conduct a set of among-chain swaps for the ptMCMC algorithm

step_chains() propose_step() eval_step() take_step()

Conduct a within-chain step of the ptMCMC algorithm

proposed_step_mods()

Fit the chunk-level models to a time series, given a set of proposed change points within the ptMCMC algorithm

Time Series on LDA output

Functions to facilitate connection running multiple TS models on LDA output

TS_on_LDA() check_TS_on_LDA_inputs()

Conduct a set of Time Series analyses on a set of LDA models

package_TS_on_LDA()

Package the output of TS_on_LDA

print(<TS_on_LDA>)

Print a set of Time Series models fit to LDAs

expand_TS()

Expand the TS models across the factorial combination of LDA models, formulas, and number of change points

prep_TS_data()

Prepare the model-specific data to be used in the TS analysis of LDA output

select_TS()

Select the best Time Series model

print_model_run_message()

Print the message to the console about which combination of the Time Series and LDA models is being run

Simulation

Functions for simulating input data

sim_LDA_data()

Simulate LDA data from an LDA structure given parameters

sim_TS_data()

Simulate TS data from a TS model structure given parameters

sim_LDA_TS_data()

Simulate LDA_TS data from LDA and TS model structures and parameters

Control options

Functions to set function options defined through control lists

LDA_TS_control()

Create the controls list for the LDATS model

LDA_set_control()

Create control list for set of LDA models

TS_control()

Create the controls list for the Time Series model

prep_LDA_control()

Set the control inputs to include the seed

Input checking

Functions to tidy code by condensing input object verification

check_changepoints()

Check that a set of change point locations is proper

check_control()

Check that a control list is proper

check_document_covariate_table()

Check that the document covariate table is proper

check_document_term_table()

Check that document term table is proper

check_formula()

Check that a formula is proper

check_formulas()

Check that formulas vector is proper and append the response variable

check_LDA_models()

Check that LDA model input is proper

check_nchangepoints()

Check that nchangepoints vector is proper

check_seeds()

Check that nseeds value or seeds vector is proper

check_timename()

Check that the time vector is proper

check_topics()

Check that topics vector is proper

check_weights()

Check that weights vector is proper

Utilities

A variety of helpful little functions

AICc()

Calculate AICc

document_weights()

Calculate document weights for a corpus

iftrue()

Replace if TRUE

logsumexp()

Calculate the log-sum-exponential (LSE) of a vector

modalvalue()

Determine the mode of a distribution

memoise_fun()

Logical control on whether or not to memoise

messageq()

Optionally generate a message based on a logical input

mirror_vcov()

Create a properly symmetric variance covariance matrix

normalize()

Normalize a vector

softmax()

Calculate the softmax of a vector or matrix of values

Data and Package

Datasets provided and the package

jornada

Jornada rodent data

rodents

Portal rodent data

LDATS

Package to conduct two-stage analyses combining Latent Dirichlet Allocation with Bayesian Time Series models