# Generate responses of 1000 people according to Warner's model
# with an underlying true proportion of .3
df <- RRgen(n = 1000, pi = .3, model = "Warner", p = .7)
head(df)
# Analyse univariate data to estimate prevalence 'pi'
estimate <- RRuni(response = df$response, model = "Warner", p = .7)
summary(estimate)
# Generate data in line with the Stochastic Lie Detector
# assuming that 90% of the respondents answer truthfully
df2 <- RRgen(
n = 1000, pi = .3, model = "SLD", p = c(.2, .8),
complyRates = c(.8, 1), groupRatio = 0.4
)
estimate2 <- RRuni(
response = df2$response, model = "SLD",
p = c(.2, .8), group = df2$group
)
summary(estimate2)
Run the code above in your browser using DataLab