Skip to content

Add information on reference documents to predict.textmodel_wordscores #1229

Description

@stefan-mueller

As far as I see, the predict() function for textmodel_wordscores() only contains the document names and the estimated scores. As a result, based on the predict() output we do not which documents were originally reference texts.

This could be somewhat problematic if a user plots the estimated scores with textplot_scale1d(margin = c("documents")), but only wants the scores for the virgin texts (or wants to highlight which documents were reference texts with a different shape/colour).

To add information on the reference documents, it would probably sufficient to add the textscore/NA to the predict.textodel_wordscores function. Then we could also adjust textplot_scale1d() and add an option such as include_refscores = FALSE or highlight_refscores = TRUE.

ws <- textmodel_wordscores(data_dfm_lbgexample, c(seq(-1.5, 1.5, .75), NA))

summary(ws)

# information on reference scores
ws$y
# > ws$y
# [1] -1.50 -0.75  0.00  0.75  1.50    NA

str(predict(ws))
# > str(predict(ws))
# Classes 'predict.textmodel_wordscores', 'numeric'  Named num [1:6] -1.32 -7.40e-01 -8.67e-18 7.40e-01 1.32 ...
# ..- attr(*, "names")= chr [1:6] "R1" "R2" "R3" "R4" ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions