estimateIdeology: Estimates ideology for a given Twitter user

Description Usage Arguments Value Author(s) Examples

View source: R/estimate-ideology.R

Description

estimateIdeology estimates ideology for a given user using the Metropolis algorithm developed in Barbera (2015). It takes as argument of the function a list of user IDs indicating who a given user follows.

Usage

1
2
estimateIdeology(user, friends, verbose = TRUE, method = "MCMC",
  iters = 5000, n.warmup = 1000, thin = 20, ...)

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.

method

"MCMC" (default) for the Metropolis algorithm described in the paper. "MLE" will use simple maximum likelihood estimation to compute the point estimate. Note that the standard error for the ML method is likely to be wrong.

iters

number of iterations of the metropolis algorithm. Default is 5000

n.warmup

warmup period for the sampler. Default is 1000 iterations.

thin

thinning of the sampler. Default is 20.

...

other options to be passed to the estimation functions

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
13
14
15
16
## 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 <- estimateIdeology(friends)
 results['theta', 'mean']
## estimating ideology using ML (fast) method
 results <- estimateIdeology(friends, method="ML")
 results['theta', 'mean']

## End(Not run)

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