generate_slopes: Generating parameters of items - slopes (discrimination)

Description Usage Arguments Details Value See Also Examples

View source: R/generate_items_parameters.R

Description

Function generates a matrix of items' slope (discrimination) parameters.

Usage

1
2
3
4
5
6
7
8
9
generate_slopes(
  nItems,
  scoringMatrix,
  ...,
  FUN = identity,
  nReversed = 0L,
  reverseTraits = "i",
  reverseIndep = FALSE
)

Arguments

nItems

number of items for which slopes will be generated

scoringMatrix

scoring matrix that will be used for the generated items, specifically generated with make_scoring_matrix_aem or make_scoring_matrix_trivial

...

arguments that will be passed to FUN; should rather be named and in typical applications should be numeric vectors of the length of one or of the number of columns of the scoringMatrix

FUN

function that will be used to generate slopes, typically

nReversed

number of reversed (revers-keyed) items, i.e. items that

reverseTraits

character vector containing names of traits for which items should be reversed (if nReversed > 0); default value is "i", that is the name assigned to the trait that is assumed to describe the trait that scale is supposed to measure (i.e. trait that is not related with response styles) by make_scoring_matrix_aem when called with argument sequence = "simultaneous"

reverseIndep

logical value indicating whether sampling items that are reversed should be performed independently for each trait (given by reverseTraits) or for all the traits simultaneously (this argument is only considered if nReversed > 0 and there is more than one trait given by reverseTraits) Normal, Lognormal, Uniform or rtruncnorm - see details

Details

There are two typical ways of using this function (compare examples below):

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).

Value

Matrix of nItems rows and number of columns equal to the length of vectors provided by ....

See Also

generate_intercepts, make_test

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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 = "simultaneous")
generate_slopes(10, sM, FUN = rnorm, mean = 1, sd = 0.2,
                nReversed = 5, reverseTraits = "i")

rstyles documentation built on July 23, 2021, 5:07 p.m.