| m3dist | R Documentation |
Density and random generation functions for the memory measurement model. Please note that these functions are currently not vectorized.
dm3(x, pars, m3_model, act_funs = NULL, log = TRUE, ...)
rm3(n, size, pars, m3_model, act_funs = NULL, unpack = FALSE, ...)
x |
Integer vector of length |
pars |
A named vector of parameters of the memory measurement model.
Note: The fixed parameter |
m3_model |
A |
act_funs |
A |
log |
Logical; if |
... |
can be used to pass additional variables that are used in the activation functions, but not parameters of the model |
n |
Integer. Number of observations to generate data for |
size |
The total number of observations in all categories |
unpack |
Logical; if |
dm3 gives the density of the memory measurement model, and rm3
gives the random generation function for the memory measurement model.
Oberauer, K., & Lewandowsky, S. (2019). Simple measurement models for complex working-memory tasks. Psychological Review, 126(6), 880–932. https://doi.org/10.1037/rev0000159
# Basic usage - b parameter is added automatically
model <- m3(
resp_cats = c("corr", "other", "npl"),
num_options = c(1, 4, 5),
choice_rule = "simple",
version = "ss"
)
# No need to provide b parameter
dm3(x = c(20, 10, 10), pars = c(a = 1, c = 2), m3_model = model)
rm3(n = 10, size = 100, pars = c(a = 1, c = 2), m3_model = model)
# Can also use full formula (activation formulas are extracted automatically)
full_formula <- bmf(
corr ~ b + a + c,
other ~ b + a,
npl ~ b,
a ~ 1,
c ~ 1
)
rm3(
n = 10, size = 100, pars = c(a = 1, c = 2),
m3_model = model, act_funs = full_formula
)
## Not run:
# Use with dplyr::reframe() for automatic unpacking into columns
library(dplyr)
library(tibble)
param_grid <- expand.grid(a = c(0.5, 1, 1.5), c = c(1, 2, 3))
simulated_data <- param_grid |>
rowwise() |>
reframe(
a = a,
c = c,
# unpack=TRUE returns named vector; wrap in as_tibble_row for auto-unpacking
as_tibble_row(rm3(
n = 1, size = 100, pars = c(a = a, c = c),
m3_model = model, unpack = TRUE
))
)
# Result has columns: a, c, corr, other, npl
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.