Package 'bayeslist'

Title: Bayesian Analysis of List Experiments with Prior Information
Description: Estimates Bayesian models of list experiments with informative priors. It includes functionalities to estimate different types of list experiment models with varying prior information. See Lu and Traunmüller (2021) <doi:10.2139/ssrn.3871089> for examples and details of estimation.
Authors: Xiao Lu [aut, cre], Richard Traunmüller [aut]
Maintainer: Xiao Lu <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1.4
Built: 2024-11-28 13:33:44 UTC
Source: CRAN

Help Index


The 'bayeslist' package.

Description

Estimate list experiment data applying full Bayesian approaches.

Author(s)

Maintainer: Xiao Lu [email protected]

Authors:

  • Richard Traunmüller


Fitting Bayesian sensitive item models

Description

The main function for estimating Bayesian sensitive item models. The function returns a bayeslist object that can be further investigated using standard functions such as summary, plot, print, predict, and coef. The model can be passed using a formula as in lm(). Convergence diagnotics can be performed using either print(object, "mcmc") or plot(object, "trace").

Usage

bayeslist(
  formula,
  data,
  treat,
  J,
  type = "outcome",
  nsim = 1000,
  burnin = NULL,
  thin = 1,
  CIsize = 0.95,
  nchain = 1,
  seeds = 12345,
  vb = FALSE,
  only_vb = FALSE,
  prior = NULL,
  direct_item = NULL,
  direct_item_misreport = NULL,
  double_list = NULL,
  double_list_treat = NULL,
  aux_info = NULL,
  aux_g = NULL,
  aux_h = NULL,
  BL_a = NULL,
  BL_b = NULL,
  conjugate_distance = FALSE,
  conjugate_k = NULL,
  predictvar = NULL,
  predictvar_type = "binary",
  parallel = TRUE,
  robust = FALSE
)

Arguments

formula

An object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

A data frame containing the variables in the model.

treat

Variable name of the treatment.

J

Number of control items.

type

Type of the model. Options include "outcome", "predict", "misreport", for the sensitive item outcome model, predictor model and misreport model, respectively.

nsim

The number of iterations.

burnin

The number of burnin iterations.

thin

Thinning parameter.

CIsize

The size of posterior confidence interval.

nchain

The number of parallel chains.

seeds

Random seeds to replicate the results.

vb

Logic. If TRUE, variational approximation will be used to supply initial values. The default is FALSE.

only_vb

Logic. If TRUE, only variational approximation will be calculated. The default is FALSE.

prior

Prior types. Options include "auxiliary", "double_list", "direct_item", and "BL" for beta-logistic prior. If NULL, no informative priors will be used.

direct_item

Variable name of the direct item.

direct_item_misreport

Variable name of the direct item for the misreporting model.

double_list

Variable name of the second list.

double_list_treat

Treatment variable of the second list.

aux_info

Auxiliary information for the informative priors. list(G,h,g), where: G (number of subgroups), h (auxiliary information for each subgroup), and g (subgroup indicator). If is.NULL, the following two parameters need to be specified when estimating the model with prior = "auxiliary".

aux_g

Auxiliary information for the informative priors: name of the variable indicating the group of each observation.

aux_h

Auxiliary information for the informative priors: name of the variable containing information of prevalence for each group

BL_a

The first shape hyperparameter for the beta-logistic prior, indicating the prior number of affirmative answers to the sensitive item.

BL_b

The second shape hyperparameter for the beta-logistic prior, indicating the prior number of non-affirmative answers to the sensitive item.

conjugate_distance

Logic. Indicating whether conjugate distance prior should be used. The default is FALSE.

conjugate_k

Degrees of freedom to be scaled by conjugate distance prior. The default is NULL.

predictvar

Variable name of the outcome to be predicted.

predictvar_type

The type of the outcome variable to be predicted. Options include "linear" and "binary". The default is "binary".

parallel

Logic. Indicating whether to do paralell computing. The default is TRUE.

robust

Logic. Indicating whether to impose robust constraints on the intercept-only model. The default is FALSE.

Value

A bayeslist object. An object of class bayeslist contains the following elements

Call

The matched call.

formula

Symbolic representation of the model.

type

Model type

nsim

Number of iterations.

Burnin

Number of burnin iterations.

thin

Thinning.

seeds

Random seeds for reproducibility. The default is 12345.

CIsize

Size of the posterior confidence interval.

data

Data used.

X

Independent variables.

Y

Dependent variables.

xnames

Names of the independent variables.

stanfit

Output from stan.

sampledf

Posterior samples.

summaryout

Summary of the stan-fit object.

npars

Number of control variables.

only_vb

Whether only viariational approximation is used.

prior

Informative prior types.

direct_item

Direct item.

double_list

The second list.

aux_info

Auxiliary information.

ulbs

Upper and lower bounds based on the specified confidence interval.

means

Mean estimates.

treat

Treatment.

outcome

Outcome to be predicted.

direct

Direct item for the misreport model.

robust

Robust indicator.

References

Lu, X. and Traunmüller, R. (2021). Improving Studies of Sensitive Topics Using Prior Evidence: A Unified Bayesian Framework for List Experiments, SSRN, doi:10.2139/ssrn.3871089.

Examples

# Estimate sensitive item outcome model using Sri Lanka data on male sexual violence
# Load Sri Lanka list experiment data
data(srilanka)

# Model 1: intercept-only outcome model without prior information:
mod1 <- bayeslist(sexaussault ~ 1, data = srilanka, treat = "treatment", J = 3,
type = "outcome", nsim = 200, thin = 1, CIsize = 0.95, nchain = 1,
seeds = 342321, prior = NULL, parallel = TRUE)
summary(mod1) # summary of estimates
predict(mod1) # predicted prevalence for each observation
plot(mod1,"trace") # trace plot
plot(mod1,"coef") # coefficient plot
plot(mod1, only_prev = TRUE) # prevalence plot


# Model 2: multivariate outcome model without prior information:
mod2 <- bayeslist(sexaussault ~ age + edu, data = srilanka, treat = "treatment", J = 3,
type = "outcome", nsim = 200, thin = 1, CIsize = 0.95, nchain = 1,
seeds = 342321, prior = NULL, parallel = TRUE)
summary(mod2) # summary of estimates
predict(mod2) # predicted prevalence for each observation
plot(mod2,"trace") # trace plot
plot(mod2,"coef") # coefficient plot
plot(mod2) # prevalence + coefficient plot

# Model 3: intercept-only outcome model with prior information from medicolegal reports, i.e.,
# with a prior beta-logistic distribution BL(38, 146).
a <- 38; b <-146
mod3 <- bayeslist(sexaussault ~ 1, data = srilanka, treat = "treatment", J = 3,
type = "outcome", nsim = 200, thin = 1, CIsize = 0.95, nchain = 1,
seeds = 342321, prior = "BL", BL_a = a, BL_b = b,, parallel = TRUE)
summary(mod3)
predict(mod3)
plot(mod3,"trace")
plot(mod3,"coef")
plot(mod3, only_prev = TRUE)

# Model 4: multivariate outcome model with prior information from a direct item.
# Load London list experiment data
data(london)
mod4 <- bayeslist(listCount ~ agegrp + gender + social_grade + qual,data = london, J = 4,
treat = "listTreat", seeds = 4597, nsim = 200, nchain = 1,
prior = "direct_item", direct_item = "baselineTurnout")
summary(mod4)
predict(mod4)
plot(mod4,"trace")
plot(mod4,"coef")
plot(mod4)

Extract coefficients from a bayeslist object

Description

Create a table of coefficient results from a bayeslist object.

Usage

## S3 method for class 'bayeslist'
coef(object, ...)

Arguments

object

A bayeslist object from running the main function bayeslist.

...

Further arguments to be passed according to coef.

Value

A table of coefficients with their corresponding lower and upper bounds.


Logistic function

Description

Standard logistic function.

Usage

logistic(x)

Arguments

x

A scalar or vector to be logit-transformed.

Value

logit-transformed value


The 2017 London List Experiment

Description

This dataset is the 2017 London list experiment on voter turnout fielded via online YouGov survey of a sample of 3189 Greater Londoners.The main question reads as follows: The next question deals with the recent general election on 8th June. Here is a list of four (five) things that some people did and some people did not do during the election campaign or on Election Day. Please say how many of these things you did. Here are the four (five) things: (1) Discussed the election with family and friends; (2) (Voted in the election); (3) Criticised a politician on social media; (4) Avoided watching the leaders debates; (5) Put up a poster for a political party in my window or garden. How many of these things did you do? The second item in bracket is the sensitive item. In addition to the above list, there is a direct question asking about turnout: Talking with people about the recent general election on 8th June, we have found that a lot of people didn't manage to vote. How about you, did you manage to vote in the general election?

Format

A data frame containing the following 18 variables for 3189 observations.

ID integer Respondent ID number.
age integer Respondent age in years.
agegrp factor Respondent age group.
gender factor YouGov panel measure of gender.
social_grade factor YouGov panel measure of respondent social grade.
qual factor Measure of highest educational qualification from YouGov panel.
validationfactor factor Detailed measure of turnout validation outcome for respondent.
validturnout integer Summary measure of true respondent turnout.
direct integer Response to direct turnout question asked of list experiment control group.
baselineTurnout integer Response to baseline direct turnout question after the election.
listTreat integer Indicator for list experiment treatment group.
listCount integer Reported item count for list experiment question.
qtime numeric Time taken to answer list experiment question, in seconds.
recallfirst character Respondent recall of first item from list question. Open text response.
recalllast character Respondent recall of last item from list question. Open text response.
recallfirst.hand.correct factor Did respondent correctly recall first list experiment item?
recalllast.hand.correct factor Did respondent correctly recall last list experiment item?
comfort numeric How comfortable do you feel revealing whether you did/did not vote in last election?

Source

The full data set is available at doi:10.7910/DVN/W90Q7B)

References

Kuhn, P. M., & Vivyan, N. (2021). The misreporting trade-off between list experiments and direct questions in practice: Partition validation evidence from two countries. Political Analysis, 1-22.


Make coefficient plots for a bayeslist object

Description

plot_coef.bayeslist is used to produce coefficient plots from a bayeslist object.

Usage

plot_coef.bayeslist(object, ...)

Arguments

object

A bayeslist object from running the main function bayeslist.

...

Additional parameters to be passed to stan_plot.

Value

None.


Plots of prevalence for bayeslist

Description

plot_prevalence.bayeslist is used to produce plots of prevalence from a bayeslist object from the main function bayeslist.

Usage

plot_prevalence.bayeslist(
  object,
  covariate_names = NULL,
  only_prev = FALSE,
  xlim = NULL,
  inverse = FALSE,
  digit = 3,
  ...
)

Arguments

object

A bayeslist object from running the main function bayeslist.

covariate_names

Names of covariates.

only_prev

Indicating whether only prevalence will be plotted. The default is FALSE.

xlim

Limits of x-axis.

inverse

Indicating whether prevalence should be calculated in the reverse order. The default is FALSE.

digit

Digit number to be displayed.

...

Additional parameters to be passed.

Value

None.


Trace plots for bayeslist

Description

plot_trace.bayeslist is used to produce trace plots from a bayeslist object from the main function bayeslist.

Usage

plot_trace.bayeslist(object, ...)

Arguments

object

A bayeslist object from running the main function bayeslist.

...

Additional parameters to be passed to traceplot.

Value

None.


Plot bayeslist object

Description

General plot function for bayeslist objects, which dispatches the chosen type of plotting to the corresponding function.

Usage

## S3 method for class 'bayeslist'
plot(x, type = "prevalence", ...)

Arguments

x

A bayeslist object to be plotted.

type

Character string giving the type of plotting. The options are "trace" for trace plots, "prevalence" for prevalence plots. The default is "prevalence".

...

Additional arguments to be passed to subsequent plot functions (check the See Also section).

Value

None.

See Also

plot_trace.bayeslist and plot_coef.bayeslist.


Predicted prevalence from a bayeslist object

Description

Prediction function for bayeslist objects.

Usage

## S3 method for class 'bayeslist'
predict(object, ...)

Arguments

object

A bayeslist object to be summarized.

...

Additional arguments to be passed to summary function.

Value

None.

See Also

print_text.bayeslist, print_mcmc.bayeslist, print_coef.bayeslist.


Print returns from a bayeslist object

Description

General print function for bayeslist objects, which dispatches the chosen type of printing to the corresponding function.

Usage

## S3 method for class 'bayeslist'
print(x, type = "text", ...)

Arguments

x

A bayeslist object to be printed.

type

Character string giving the type of printing, such as "text", "mcmc", "coef".

...

Additional arguments to be passed to print functions (check the See Also section).

Value

None.

See Also

print_text.bayeslist, print_mcmc.bayeslist, print_coef.bayeslist.


The Sri Lanka List Experiment on Wartime Sexual Violence

Description

This dataset, which includes male respondents from Tamil, is a subset of the list experiment administered in Sri Lanka on wartime sexual violence.The main question reads as follows: Now we would like to ask you some more questions about what happened during the war. Please refer to the following list and tell me how many of these experiences happened to you during the war. Please don’t tell me which specific statements you believe to be true, only how many: (1) I won money in a lottery or competition; (2) I was involved in an accident; (3) I received help from a stranger; (4) (I was personally sexually assaulted.) The forth item in bracket is the sensitive item. In addition to the above list, there are also two direct questions asking about sexual abuse.

Format

A data frame containing the following 9 variables for 247 observations.

sexaussault integer Reported item count for list experiment question.
sexaussault_d integer First direct item.
sexaussault_d2 integer Second direct item.
treatment integer Indicator for list experiment treatment group.
age numeric Age.
edu integer Education.
eastern integer Whether the respondent comes from eastern Tamil.
assist.army integer Whether the respondent has assisted rebel groups.
displace integer Displacement.

References

Traunmüller, R., Kijewski, S., & Freitag, M. (2019). The silent victims of sexual violence during war: Evidence from a list experiment in Sri Lanka. Journal of conflict resolution, 63(9), 2015-2042. doi:10.1177/0022002719828053


Summary of a bayeslist object

Description

General summary function for bayeslist objects.

Usage

## S3 method for class 'bayeslist'
summary(object, ...)

Arguments

object

A bayeslist object to be summarized.

...

Additional arguments to be passed to summary function.

Value

None.

See Also

print_text.bayeslist, print_mcmc.bayeslist, print_coef.bayeslist.