extract.estimateEffect: Extract effect of covariates on topics

Description Usage Arguments Examples

View source: R/extractEffect.R

Description

Extracts the effect of a covariate on a set of topics selected by the user. Different effect types available depending on type of covariate. Before running this, the user should run a function to simulate necessary confidence intervals. See link{estimateEffect}.

Usage

1
2
3
4
5
extract.estimateEffect(x, covariate, model = NULL, topics = x$topics,
  method = "pointestimate", cov.value1 = NULL, cov.value2 = NULL,
  moderator = NULL, moderator.value = NULL, npoints = 100, nsims = 100,
  ci.level = 0.95, custom.labels = NULL, labeltype = "numbers", n = 7,
  frexw = 0.5)

Arguments

x

Output of estimateEffect, which calculates simulated betas for plotting or extraction.

covariate

String of the name of the main covariate of interest. Must be enclosed in quotes. All other covariates within the formula specified in estimateEffect will be kept at their median.

model

Model output, only necessary if labeltype is "prob", "frex", "score", or "lift". Models with more than one spline cannot be used for extract.estimateEffect.

topics

Topics to plot.

method

Method used for plotting. "pointestimate" estimates mean topic proportions for each value of the covariate. "difference" estimates the mean difference in topic proportions for two different values of the covariate (cov.value1 and cov.value2 must be specified). "continuous" estimates how topic proportions vary over the support of a continuous covariate.

cov.value1

For method "difference", the value or set of values of interest at which to set the covariate. In the case of calculating a treatment/control contrast, set the treatment to cov.value1.

cov.value2

For method "difference", the value or set of values which will be set as the comparison group. cov.value1 and cov.value2 must be vectors of the same length.

moderator

When two terms are interacted and one variable in the interaction is the covariate of interest, the user can specify the value of the interaction with moderator.value, and the name of the moderator with moderator.

moderator.value

When two terms are interacted and one variable in the interaction is the covariate of interest, the user can specify the value of the interaction term.

npoints

Number of unique points to use for simulation along the support of a continuous covariate. For method "continuous" only.

nsims

Number of simulations for estimation.

ci.level

Confidence level for confidence intervals.

custom.labels

A vector of custom.labels if labeltype is equal to "custom".

labeltype

Determines the labeltype for the topics. The default is "number" which prints the topic number. Other options are "prob", which prints the highest probability words, "score", "lift", and "frex", from labeltopics (see stm::labeltopics() for more details). The user can also select "custom" for custom labels, which should be inputted under custom.labels. Labels appear in the legend for continous covariates.

n

Number of words to print if "prob", "score", "lift", or "frex" is chosen. to signal how far the function have come.

frexw

If "frex" labeltype is used, this will be the frex weight.

Examples

1
2
3
4
5
## Not run: 
prep <- estimateEffect(1:3 ~ treatment, gadarianFit, gadarian)
effect <- extract.estimateEffect(prep, "treatment", model = gadarianFit, method = "pointestimate")

## End(Not run)

mikaelpoul/tidystm documentation built on April 30, 2020, 12:30 p.m.