'Proper settings for plot.estimateEffect in stm package

The stm package provides an indispensable set of tools for estimating the effect of covariates on topic prevalence. The plot.estimateEffect() function in particular displays helpful pointrange plots to visualize this effect. However, I find the documentation for plot.estimateEffect() confusing.

This is a silly question, but I want to make absolutely sure I understand this right. Suppose I have a binary covariate ("cov") of {0,1} that I want to use to predict topic prevalence. I input the following arguments:

covariate = "cov"
cov.value1 = 1
cov.value2 = 0

The documentation says to "set the treatment to cov.value1." I do so: in this case, "1" is the treatment, "0" is the control.

The numeric labels are confusing me, since my covariate is also numeric.

When I do this without a custom topic label, the default labels read "Topic X (Covariate Level 1 Compared to 0)", which seems to imply that "1" refers to the left-hand side (and vice versa for "0"). This would seem to confirm that the left-hand side of the x-axis (negative numbers) should represent topic prevalence when cov=1, and the right-hand side (positive numbers) represent cov=0.

However, the sign of the point estimates seems wrong to me with these settings.

When cov.value1 is set to 1 and cov.value2 is set to 0, Topic 1 (which contains a higher proportion of "xxxx" and "yyyy") is right-shifted (toward what the documentation states is the control condition). But given the values of "cov", Topic 1 should appear more often in the treatment condition (when cov=1). ["xxxx" and "yyyy" appear more often when cov=1 (1/2+1/3+1/3) than when cov=0 (1/4+1/2+1/3+1/3).]

I guess the confusion stems from the label names (of what is otherwise a fantastic package). I would find this much more straightforward if the relevant arguments were labeled treatment.value and control.value, for example.

Intuitively I would have expected the plot to show the effect as we move from control to treatment, not treatment to control. Is the documentation right? Does the left-hand side represent treatment (cov.value1), and the right-hand side control (cov.value2)? If so, please help me understand why the sign is in the unexpected direction.

MWE:

library(quanteda)
library(stm)

text_field <- c("xxxx kjbregioberg", "yyyy owbhgoer ergo ergu", "xxxx yyyy fwkbekfbk ew", "xxxx wf ibgfbgr ", "yyyy gf gds", "yyyy frgg fgfg", "yyyy eee ef ")
cov <- c(1, 0, 0, 1, 1, 0, 0)

corp <- as.data.frame(cbind(text_field, cov))
corp$cov <- as.numeric(corp$cov)
corp$text_field <- as.character(corp$text_field)

corp <- corpus(corp, text_field = "text_field")

dfm <- dfm(corp)

dfm <- convert(dfm, to = "stm", docvars = docvars(dfm))

stm_object <- stm(documents = dfm$documents,
                          vocab = dfm$vocab,
                          data = dfm$meta,
                          prevalence = ~ cov, 
                          K = 2, seed = 1, init.type = "Spectral")

topics_outcome <- 1:2

stm_effects <- estimateEffect(topics_outcome ~ cov,  # +
                                 stmobj = stm_object,
                                 meta = dfm$meta,
                                 uncertainty = "Global")

plot.estimateEffect(stm_effects, 
                    covariate = "cov", 
                    topics = topics_outcome,
                    model = stm_object,
                    method = "difference",
                    cov.value1 = 0,
                    cov.value2 = 1, 
                    xlim = c(-1, 1),
                    cex = 1.5,
                    main = "",
                    xlab = "0                                 1"
)


Solution 1:[1]

I found this. It may helps 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.

Find more https://cran.r-project.org/web/packages/stm/stm.pdf

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 eirinivl