generate_slopes: Generating parameters of items - slopes (discrimination)

View source: R/generate_item_parameters.R

generate_slopesR Documentation

Generating parameters of items - slopes (discrimination)

Description

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

Usage

generate_slopes(
  nItems,
  scoringMatrix,
  ...,
  FUN = identity,
  nReversed = 0L,
  reverseTraits = "i",
  reverseIndep = FALSE
)

Arguments

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

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 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 = "gpcm"

reverseIndep

a 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):

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

Value

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

See Also

generate_intercepts, make_test

Examples

# 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")

tzoltak/rstyles documentation built on Dec. 4, 2024, 5:16 p.m.