textmodel_wordshoal: Wordshoal text model

Description Usage Arguments Details Value Author(s) References Examples

View source: R/textmodel_wordshoal.R

Description

Estimate Lauderdale and Herzog's (2016) model for one-dimensional document author (e.g. speakers) positions based on multiple groups of texts (e.g. debates). Each group of texts is scaled using Slapin and Proksch's (2008) "wordfish" Poisson scaling model of one-dimensional document positions, and then the positions from a particular author are scaled across groups using a second-level linear factor model, using conditional maximum likelihood.

Usage

1
textmodel_wordshoal(x, groups, authors, dir = c(1, 2), tol = 0.001)

Arguments

x

the quanteda dfm from which the model will be fit

groups

the name of a variable in the document variables for data giving the document group for each document

authors

the name of a variable in the document variables for data giving the author of each document

dir

set global identification by specifying the indexes for a pair of authors such that \hat{θ}_{dir[1]} < \hat{θ}_{dir[2]}

tol

a convergence threshold for the log-posterior of the model

Details

Returns estimates of relative author positions across the full corpus of texts.

Value

An object of class textmodel_wordshoal. This is a list containing:

tol

log-posterior tolerance used in fitting

dir

global identification of the dimension

theta

estimated document positions

beta

debate marginal effects

alpha

estimated document fixed effects

psi

estimated document debate-level positions

groups

document groups

authors

document authors

ll

log likelihood at convergence

se.theta

standard errors for theta-hats

data

corpus to which the model was fit

Author(s)

Benjamin Lauderdale and Kenneth Benoit

References

Benjamin E. Lauderdale and Alexander Herzog. 2016. "Measuring Political Positions from Legislative Speech." Political Analysis 24 (3, July): 374-394.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library("quanteda")
iedfm <- dfm(data_corpus_irish30, remove_punct = TRUE) 

wordshoalfit <- 
    textmodel_wordshoal(iedfm, dir = c(7,1),
                        groups = docvars(data_corpus_irish30, "debateID"), 
                        authors = docvars(data_corpus_irish30, "member.name"))
summary(wordshoalfit)                    
author_positions <- summary(wordshoalfit)$estimated.author.positions
author_positions$row_names <- rownames(author_positions)
fitdf <- merge(author_positions,
               docvars(data_corpus_irish30), 
               by.x = "row_names", by.y = "member.name")
fitdf <- subset(fitdf, !duplicated(memberID))
aggregate(theta ~ party.name, data = fitdf, mean)

kbenoit/wordshoal documentation built on May 8, 2020, 4:18 a.m.