estimateIdeology2: Estimates ideology for a given Twitter user

Description Usage Arguments Value Author(s) Examples

View source: R/estimate-ideology2.R

Description

estimateIdeology2 estimates ideology for a given user using the method described in Barbera et al, 2015, Psychological Science. It projects each user onto a latent ideological space using correspondence analysis, assuming that all else is constant, and relying on the column estimates in the paper. The values are then normalized to a N(0,1) distribution.

Usage

1
2
estimateIdeology2(user, friends, verbose = TRUE, exact = FALSE,
  replace_outliers = FALSE)

Arguments

user

screen name of user for which ideology is to be estimated.

friends

vector of user IDs that the user for which ideology wants to be estimated follows. If missing, getFriends is called for the value of user.

verbose

logical, default is TRUE, which generates some output to the R console with information about progress of the sampler.

exact

logical, default is FALSE, which adds some random noise (from a normal distribution with mean 0 and standard deviation 0.05) to avoid spikes in distribution of ideal points. See https://github.com/pablobarbera/echo_chambers/blob/master/02_estimation/11-second-stage.r for details.

replace_outliers

logical, default is FALSE, which will not replace any values that are estimated to be -Inf or Inf. These values will correspond to users with an ideology estimate outside the range of the users in the original training set (from -2.32 to 2.32). If TRUE, the -Inf or Inf values will be replaced with a random sample from the normal distribution below -2.32 (for -Inf) or above 2.32 (for Inf).

Value

The function returns a matrix with summary statistics of the posterior distribution of the two estimated parameters, beta (political interest) and theta (ideology).

Author(s)

Pablo Barbera P.Barbera@lse.ac.uk

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
## Creating OAuth token
 my_oauth <- list(consumer_key = "CONSUMER_KEY",
   consumer_secret = "CONSUMER_SECRET",
   access_token="ACCESS_TOKEN",
   access_token_secret = "ACCESS_TOKEN_SECRET")
## download list of friends for a given user
 friends <- getFriends(screen_name = "p_barbera", oauth=my_oauth)
## estimating ideology
 results <- estimateIdeology2(friends)

## End(Not run)

lingeringcode/tweetscoresmod documentation built on Feb. 18, 2020, 5:28 p.m.