View source: R/generate_item_parameters.R
generate_slopes | R Documentation |
Function generates a matrix of items' slope (discrimination) parameters.
generate_slopes(
nItems,
scoringMatrix,
...,
FUN = identity,
nReversed = 0L,
reverseTraits = "i",
reverseIndep = FALSE
)
nItems |
the number of items for which slopes will be generated |
scoringMatrix |
a scoring matrix that will be used for the
generated items, specifically generated with
|
... |
arguments that will be passed to |
FUN |
a function that will be used to generate slopes, typically |
nReversed |
the number of reversed (revers-keyed) items |
reverseTraits |
a character vector containing names of traits for which
items should be reversed (if |
reverseIndep |
a logical value indicating whether sampling items that are
reversed should be performed independently for each trait (given by
|
There are two typical ways of using this function (compare examples below):
If one wants to generate constant slopes for all the items, one should simply provide a vector which elements describe slope for each of the consecutive traits. You may name elements of this vector to get this names assigned to columns of the returned matrix.
If one wants to sample slopes using specific distribution, one
must provide a sampling function using FUN
argument.
Arguments that should be passed to this function one should provide
as additional arguments to a generate_slopes
call. If one
wants to generate slopes for more than one trait, one needs to
provide at least one of these arguments as a vector with as many
elements, as there are traits (even if all of its elements would be
equal). Moreover one may name elements of this vector, to get these
names assigned to columns of the returned matrix. Other arguments may
be provided as single values if one wants to hold them constant
across traits.
In a case slopes are sampled, this is done independently for each of the
traits. The same sampling function is used for each trait and there is no
way to change this (but one may still use cbind
to collapse
results of several separate generate_slopes
calls to achieve this
goal).
A matrix of nItems
rows and number of columns equal to the
length of vectors provided by ...
.
generate_intercepts
, make_test
# 5 items with slopes equals 1 on all the latent traits
sM <- make_scoring_matrix_aem(5, sequence = "mae")
generate_slopes(5, sM, 1)
# 10 items with slopes on all the latent traits generated from a uniform
# distribution with limits 0.5 and 3
sM <- make_scoring_matrix_aem(5, sequence = "mae")
generate_slopes(10, sM, FUN = runif, min = 0.5, max = 3)
# 10 items with slopes generated from a normal distributions with parameters set to:
# trait 'm' (i.e. the first column in the scoring matrix): mean 1, sd 0.2
# trait 'a' (i.e. the second column in the scoring matrix): mean 1.2, sd 0.3
# trait 'e' (i.e. the third column in the scoring matrix): mean 1.5, sd 0.5
sM <- make_scoring_matrix_aem(5, sequence = "mae")
generate_slopes(10, sM, FUN = rnorm,
mean = c(1, 1.2, 1.5),
sd = c(0.2, 0.3, 0.5))
# 10 items with slopes generated from a truncated-normal distributions with
# parameters set to:
# trait 'm' (i.e. the first column in the scoring matrix): mean 1, sd 0.5
# trait 'a' (i.e. the second column in the scoring matrix): mean 1.2, sd 0.7
# trait 'e' (i.e. the third column in the scoring matrix): mean 1.5, sd 1
# and bounds equals to 0.5 (lower) and 2.5 (upper) for all the traits
sM <- make_scoring_matrix_aem(5, sequence = "mae")
require(truncnorm)
generate_slopes(10, sM, FUN = rtruncnorm,
mean = c(1, 1.2, 1.5),
sd = c(0.5, 0.7, 1),
a = 0.5,
b = 2.5)
# 10 items with slopes generated from a normal distributions with mean of 1
# and standard deviation of 0.2 with half of the items "reverse-keyed" on
# the trait "i"
sM <- make_scoring_matrix_aem(5, sequence = "gpcm")
generate_slopes(10, sM, FUN = rnorm, mean = 1, sd = 0.2,
nReversed = 5, reverseTraits = "i")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.