Calculate posterior draws of respondent proficiency. Optionally retain all posterior draws or return only summaries of the distribution for each respondent.
Usage
score(
x,
newdata = NULL,
missing = NA,
identifier = NULL,
summary = TRUE,
probs = c(0.025, 0.975),
force = FALSE
)
Arguments
- x
An estimated model (e.g., from
dcm_estimate()
.- newdata
Optional new data. If not provided, the data used to estimate the model is scored. If provided,
newdata
should be a data frame with 1 row per respondent and 1 column per item. All items that appear innewdata
should appear in the data used to estimatex
.- missing
An
R
expression specifying how missing data indata
is coded (e.g.,NA
,"."
,-99
, etc.). The default isNA
.- identifier
Optional. Variable name of a column in
newdata
that contains respondent identifiers.NULL
(the default) indicates that no identifiers are present in the data, and row numbers will be used as identifiers. Ifnewdata
is not specified and the data used to estimate the model is scored, theresp_id
is taken from the original data.- summary
Should summary statistics be returned instead of the raw posterior draws? Only relevant if the model was estimated with
method = "mcmc"
. Default isFALSE
.- probs
The percentiles to be computed by the
stats::quantile()
function. Only relevant if the model was estimated withmethod = "mcmc"
. Only used ifsummary
isTRUE
.- force
If respondent estimates have already been added to the model object with
add_respondent_estimates()
, should they be recalculated. Default isFALSE
.
Value
A list with two elements: class_probabilities
and
attribute_probabilities
.
If summary is FALSE
, each element is a tibble with one row per
respondent. The columns include the respondent identifier, and one column
of probabilities for each of the possible classes or attributes (as
posterior::rvar()
objects).
If summary is TRUE
, each element is a tibble with one row per respondent
and class or attribute. The columns include the respondent identifier,
class
or attribute
, mean
, and one column for every value specified in
probs
.