predict_ideology: predict_ideology

Description Usage Arguments Details Value Examples

View source: R/predict.R

Description

This function allows you to scale the ideological slant of Twitter posts.

Usage

1
2
predict_ideology(tweets, model = "BiLSTM", embeddings = "w2v",
  embedding_dim = 25, filter_political_tweets = FALSE)

Arguments

tweets

Character vector of Tweets.

model

Neural network architecture to use. Options are "LSTM", "BiLSTM", or "C-BiLSTM".

embeddings

Type of word embedding algorithm to use. Options are "w2v" (word2vec), "glove", or "random" (random initialization).

embedding_dim

Length of word embeddings to use. Options are 25, 50, 100, or 200.

filter_political_tweets

If Tweet collection may contain non-political Tweets, optionally filter them out before ideological scaling.

Details

The data set on which the models are trained is roughly 75 percent Tweets from "elite" users (e.g. politicians, media outlets, think tanks, etc.), with the remaining 25 percent coming from "mass" users. In validating the models, it became apparent that they were much more capable of identifying slant from the former group, which in many ways presents an idealized scenario of clearly- (and often forcefully-) articulated ideological leanings along with (mostly) consistent grammar and spelling. Predictions of "mass" Tweets were largely clustered around the middle of the spectrum, not because they were necessarily more moderate, but because the models could not make a confident prediction either way. Accordingly, researchers should use caution when using this package to scale Tweets from groups other than poltiical elites.

The Tweets used to train the models were scraped and labeled in early 2018. The ideological spectrum is, of course, not a static entity, and where particular issues and actors fall on that spectrum can shift over time. Additionally, new issues and actors have emerged on the political scene since this data was collected, so stances on more recent topics (e.g. Brett Kavanaugh or the Green New Deal) that might provide a great deal of information to a political observer about someone's leanings would not provide any additional information to the model.

Value

Vector of float values between 0 and 1, where values closer to 0 indiciate liberal ideological slant, values closer to 1 indicate conservative ideological slant, and values near 0.5 indicate a lack of ideological leaning. Non-political Tweets return return a NULL value.

Examples

1
2
3
4
tweets <- c("Make no mistake- the President of the United States is actively sabotaging the health insurance of millions of Americans with this action.",
            "This MLK Day, 50 years after his death, we honor Dr. King's legacy. He lived for the causes of justice and equality, and opened the door of opportunity for millions of Americans. America is a better; freer nation because of it.",
            "I’m disappointed in Senate Democrats for shutting down the government. #SchumerShutdown")
preds <- predict_ideology(tweets, model="BiLSTM", embeddings="w2v")

alex-gottlieb/deepIdeology documentation built on Nov. 1, 2019, 9:09 p.m.