Learn R Programming

textmatching (version 0.1.0)

refit: Refit the Documents Under an Alternate Treatment Level

Description

A function to refit all the document loadings in an STM under an alternative content covariate level.

Usage

refit(stm_model, documents, content_level, verbose = TRUE)

Arguments

stm_model

the stm content covariate model from which to develop the projection

documents

the documents that we want to refit. This currently only works if these are the original documents used to fit the model. However, this same refitting procedure could be done by using fitNewDocuments in the stm.

content_level

a string containing the level under which to refit the documents

verbose

a logical indicating if progress should be printed to the screen

Value

list

content_level

the level of the content covariate

theta

the document-topic matrix refit under the new content level

Details

This function cycles through all the documents and refits the theta parameter (the document-topic loadings) as though they all had the same level of the content covariate as specified by content_level. For documents that already had that content_level the results should be very close to their originally learned value of theta if the model had converged. However, because stm is an iterative algorithm and the global parameters are updated last, they could be different.

References

Roberts, M., Stewart, B., Nielsen, R. (2020) "Adjusting for Confounding with Text Matching." In American Journal of Political Science

Examples

Run this code
# NOT RUN {
 data(sim)
 refitted <- refit(sim_topics, sim_documents, content_level="1")
# }

Run the code above in your browser using DataLab