Learn R Programming

sts (version 1.4)

heldoutLikelihood: Compute Heldout Log-Likelihood

Description

Compute the heldout log-likelihood of the STS model

Usage

heldoutLikelihood(object, missing)

Value

expected.heldout is the average of the held-out log-likelihood values for each document.

Arguments

object

an sts object, typically after applying make.heldout

missing

list of which words and documents are in the heldout set

Examples

Run this code
# \donttest{
library("tm"); library("stm"); library("sts")
temp<-textProcessor(documents=gadarian$open.ended.response,
metadata=gadarian, verbose = FALSE)
out <- prepDocuments(temp$documents, temp$vocab, temp$meta, verbose = FALSE)
out$meta$noTreatment <- ifelse(out$meta$treatment == 1, -1, 1)
out_ho <- make.heldout(out$documents, out$vocab)
out_ho$meta <- out$meta
## low max iteration number just for testing
sts_estimate <- sts(~ treatment*pid_rep, ~ noTreatment, out_ho, K = 3, maxIter = 2, verbose = FALSE)
heldoutLikelihood(sts_estimate, out_ho$missing)$expected.heldout
# }

Run the code above in your browser using DataLab