
Simulated topic effects from an STM estimateEffect() object
Source: R/topic_effects.R
topic_effects.RdTidy version of what plot.estimateEffect() draws: for each
topic, the expected topic proportion over the values of a covariate,
or the difference between two values, with simulation intervals:
"continuous": over a grid ofn_pointsvalues between the minimum and the maximum of a numeric covariate (a year, a day);"pointestimate": at each level of a categorical covariate (a type of document, a journal);"difference": betweencov_value1andcov_value2.
By default, "continuous" for a numeric covariate and
"pointestimate" otherwise.
Usage
topic_effects(
effects,
covariate,
method = NULL,
topics = NULL,
cov_value1 = NULL,
cov_value2 = NULL,
moderator = NULL,
moderator_value = NULL,
n_points = 100L,
n_sims = 500L,
ci_level = 0.95,
topic_labels = NULL,
...
)Arguments
- effects
An
estimateEffectobject (stm::estimateEffect()).- covariate
Character scalar, covariate name.
- method
"continuous","pointestimate"or"difference"(default: chosen from the type of the covariate).- topics
Integer vector of topics (default: those of
effects).- cov_value1, cov_value2
Values compared when
method = "difference".- moderator, moderator_value
Optional moderator (interaction) and its value.
- n_points
Integer scalar, number of grid points of
"continuous".- n_sims
Integer scalar, number of simulation draws.
- ci_level
Numeric scalar in (0, 1).
- topic_labels
Optional table with
topicandlabel(e.g. fromtopic_labels()).NULLlabels topics "Topic 1", "Topic 2", ...- ...
Not used: an argument renamed in the development version of mintR gives an error naming its replacement.
Value
A data.table: method, topic, label, covariate,
covariate_value, estimate, std_error, ci_level, ci_lower,
ci_upper (and moderator, moderator_value when a moderator is
given), sorted by topic and covariate value.
Details
Uses non-exported stm functions (produce_cmatrix, simBetas),
the ones plot.estimateEffect() calls, so the results are those of the
plot. The estimate is the mean of the simulations and the interval
their quantiles.