0

I got a problem while running a covariate effect on STM model in R. Any suggestions for me to solve this problem?

library(quanteda)

data <- read.csv("nr_11r.csv")
data$documents <- as.character(data$documents)
data$gender <- as.factor(data$gender)
data$date <- as.Date(data$date, "%m/%d/%Y")
data$day <- as.numeric(format(data$date, "%d"))

test <- corpus(data, text_field="documents")
test_dfm <- dfm(test, remove_punct=T, remove=stopwords("english"))     
test_dfm <- dfm_trim(test_dfm, min_termfreq = 2)
test_dfm <- test_dfm[rowSums(test_dfm) > 0, ] #remove empty rows

library(stm)
m <- stm(test_dfm, K = 40, max.em.its = 100, control=list(alpha=1))

#prevalence
m2 <- stm(test_dfm, K = 40, prevalence =~ day, max.em.its = 100)
prep <- estimateEffect(1:40 ~ day, stmobj = m2, meta = 
        docvars(test_dfm))

The error warning comes from prep: Error in posint(K) : could not find function "posint"

glts
  • 21,808
  • 12
  • 73
  • 94
puspa
  • 1
  • 2

0 Answers0