refit: Refit the Documents Under an Alternate Treatment Level

Description Usage Arguments Details Value References Examples

View source: R/refit.R

Description

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

Usage

1
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

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.

Value

list

content_level

the level of the content covariate

theta

the document-topic matrix refit under the new content level

References

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

Examples

1
2
 data(sim)
 refitted <- refit(sim_topics, sim_documents, content_level="1")

textmatching documentation built on Aug. 19, 2020, 9:06 a.m.