mtscr_model {mtscr} | R Documentation |
Create MTS model
Description
Create MTS model for creativity analysis.
Usage
mtscr_model(
df,
id_column,
item_column = NULL,
score_column,
top = 1,
prepared = FALSE,
ties_method = c("random", "average"),
normalise = TRUE,
self_ranking = NULL
)
Arguments
df |
Data frame in long format. |
id_column |
Name of the column containing participants' id. |
item_column |
Optional, name of the column containing distinct trials (e.g. names of items in AUT). |
score_column |
Name of the column containing divergent thinking scores (e.g. semantic distance). |
top |
Integer or vector of integers (see examples), number of top answers to include in the model. Default is 1, i.e. only the top answer. |
prepared |
Logical, is the data already prepared with |
ties_method |
Character string specifying how ties are treated when
ordering. Can be |
normalise |
Logical, should the creativity score be normalised? Default is |
self_ranking |
Name of the column containing answers' self-ranking.
Provide if model should be based on top answers self-chosen by the participant.
Every item should have its own ranks. The top answers should have a value of 1,
and the other answers should have a value of 0. In that case, the |
Value
The return value depends on length of the top
argument. If top
is a single
integer, a glmmTMB
model is returned. If top
is a vector of integers, a list
of glmmTMB
models is returned, with names corresponding to the top
values,
e.g. top1
, top2
, etc.
Examples
data("mtscr_creativity", package = "mtscr")
mtscr_creativity <- mtscr_creativity |>
dplyr::slice_sample(n = 300) # for performance, ignore
mtscr_model(mtscr_creativity, id, item, SemDis_MEAN) |>
summary()
# three models for top 1, 2, and 3 answers
mtscr_model(mtscr_creativity, id, item, SemDis_MEAN, top = 1:3) |>
mtscr_model_summary()
# you can prepare data first
data <- mtscr_prepare(mtscr_creativity, id, item, SemDis_MEAN)
mtscr_model(data, id, item, SemDis_MEAN, prepared = TRUE)
# extract effects for creativity score by hand
model <- mtscr_model(mtscr_creativity, id, item, SemDis_MEAN, top = 1)
creativity_score <- glmmTMB::ranef(model)$cond$id[, 1]