Description Usage Arguments Details Value References Examples
This function simulates the expectation distribution of the
observed opinion score (computed using the opi_score function).
The resulting tidy-format dataframe can be described as the
expected sentiment document (ESD) (Adepeju and Jimoh, 2021).
1 |
osd_data |
A list (dataframe). An |
nsim |
(an integer) Number of replicas (ESD) to simulate.
Recommended values are: 99, 999, 9999, and so on. Since the run time
is proportional to the number of replicas, a moderate number of
simulation, such as 999, is recommended. Default: |
metric |
(an integer) Specify the metric to utilize for the
calculation of the opinion score. Default: |
fun |
A user-defined function given that parameter
|
quiet |
(TRUE or FALSE) To suppress processing
messages. Default: |
Employs non-parametric randomization testing approach in order to generate the expectation distribution of the observed opinion scores (see details in Adepeju and Jimoh 2021).
Returns a list of expected opinion scores with length equal
to the number of simulation (nsim) specified.
(1) Adepeju, M. and Jimoh, F. (2021). An Analytical Framework for Measuring Inequality in the Public Opinions on Policing – Assessing the impacts of COVID-19 Pandemic using Twitter Data. https://doi.org/10.31235/osf.io/c32qh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #Prepare an osd data from the output
#of `opi_score` function.
score <- opi_score(textdoc = policing_dtd,
metric = 1, fun = NULL)
#extract OSD
OSD <- score$OSD
#note that `OSD` is shorter in length
#than `policing_dtd`, meaning that some
#text records were not classified
#Bind a fictitious indicator column
osd_data2 <- data.frame(cbind(OSD,
keywords = sample(c("present","absent"), nrow(OSD),
replace=TRUE, c(0.35, 0.65))))
#generate expected distribution
exp_score <- opi_sim(osd_data2, nsim=99, metric = 1,
fun = NULL, quiet=TRUE)
#preview the distribution
hist(exp_score)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.