mediascores | R Documentation |
This function is the workhorse of the mediascores library. It fits the model of news media sharing as described in more detail in the library vignette and in the "Model Details" section further below.
mediascores(
Y,
group = NULL,
anchors,
user_variance = FALSE,
variational = FALSE,
chains = 4,
cores = getOption("mc.cores", 1L),
threads = cores,
iter = 2000,
warmup = floor(iter/2),
refresh = 50,
...
)
Y |
matrix or dataframe of dimension |
group |
vector of length |
anchors |
vector of length 2 indicating the index/column position of the
anchor domains. The first index defines the meaning of lower values of
the scale; the second, upper values. For example, setting the first
value to indicate the column representing the New York Times and the
second value to represent the FOX News column would render lower values
of |
user_variance |
logical, whether to include a variance parameter for
each user (i.e. whether to include or exclude |
variational |
logical, whether variational inference is used for
estimation ( |
chains |
integer, the number of Markov chains to run (for
|
cores |
integer, the number of cores to use when running chains in parallel. |
threads |
integer, the number of total threads to use for
within-chain parallelization. Defaults to the value of |
iter |
integer, the number of total iterations per chain. Defaults to 2000. |
warmup |
integer, the number of warmup/burnin iterations per chain.
Defaults to |
refresh |
integer, the number of iterations per chain before sampling progress on each chain is displayed to the user. |
... |
additional arguments passed to |
An object of S4 class stanfit (see stanfit-class
)
representing the fitted results. You can use point_est
and
rhat
to extract point estimates and rhat values for the
posterior object.
The model fit by the mediascores()
function is a negative binomial
item-response-style model of the following form:
NegBin(\pi_{img}, \omega_i\omega_m)
\pi_{img} = \alpha_i + \gamma_m - ||\vartheta_i - \zeta_m||^2,
where \alpha_i
denotes a user-level intercept; \gamma_m
, a news
media domain intercept; \vartheta_i
the sharing-ideology of user
i
; zeta_m
the ideology of news media domain m
; and
\omega_i
and \omega_m
, user- and domain-level variance parameters.
Details regarding the priors for these parameters are discussed in the
library's vignette. A group-specific common prior distribution can be placed
on users' news-sharing ideology parameters \vartheta_i
through the
integer-valued group
argument (a vector of integers specifying the
affiliation of each user).
## Not run:
sim_data <- simulate_data(200, 500)
posterior <- mediascores(sim_data$Y, sim_data$group, sim_data$anchors,
variational = FALSE, chains = 2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.