The SPRITE algorithm aims to construct possible distributions that conform to observed/reported parameters. This function performs some checks and returns a list of these parameters that can then be passed to the functions that actually generate the distributions (e.g. find_possible_distribution)

set_parameters(
  mean,
  sd,
  n_obs,
  min_val,
  max_val,
  m_prec = NULL,
  sd_prec = NULL,
  n_items = 1,
  restrictions_exact = NULL,
  restrictions_minimum = NULL,
  dont_test = FALSE
)

Arguments

mean

The mean of the distribution

sd

The standard deviation of the distribution

n_obs

The number of observations (sample size)

min_val

The minimum value

max_val

The maximum value

m_prec

The precision of the mean, as number of digits after the decimal point. If not provided, taken based on the significant digits of mean - so only needed if reported mean ends in 0

sd_prec

The precision of the standard deviation, again only needed if reported standard deviation ends in 0.

n_items

Number of items in scale, if distribution represents scale averages. Defaults to 1, which represents any single-item measure.

restrictions_exact

Restrictions on the exact frequency of specific responses, see Details

restrictions_minimum

Restrictions on the minimum frequency of specific responses, see Details

dont_test

By default, this function tests whether the mean is possible, given the sample size (GRIM-test) and whether the standard deviation is possible, given mean and sample size (GRIMMER test), and fails otherwise. If you want to override this, and run SPRITE anyway, you can set this to TRUE.

Value

A named list of parameters, pre-processed for further rsprite2 functions.

Details

Restrictions can be used to define how often a specific value should appear in the sample. They need to be passed as a list in the form value = frequency. Thus, to specify that there should be no 3s and five 4s in the distribution, you would pass restrictions_exact = list("3" = 0, "4" = 5). To specify that there should be at least one 1 and one 7, you would pass restrictions_minimum = list("1" = 1, "7" = 1). If you just want to specify that the minimum and maximum values appear at least once (for instance when they are the reported rather than possible range), you can use the shortcut restrictions_minimum = "range". Finally, if you work with multi-item scales that result in decimal responses, round those names to two decimal points, e.g., when n_items = 3 you could specify list("1.67" = 0).

Examples


set.seed(1234) #To get reproducible results

# Simple case
sprite_parameters <- set_parameters(mean = 2.2, sd = 1.3, n_obs = 20, min_val = 1, max_val = 5)
find_possible_distribution(sprite_parameters)
#> $outcome
#> [1] "success"
#> 
#> $values
#>  [1] 2 1 4 2 1 4 1 1 2 2 1 4 3 3 1 2 4 1 5 1
#> 
#> $mean
#> [1] 2.25
#> 
#> $sd
#> [1] 1.332785
#> 
#> $iterations
#> [1] 2
#> 

# With restrictions
sprite_parameters <- set_parameters(mean = 1.95, sd = 1.55, n_obs = 20,
                                    min_val = 1, max_val = 5, n_items = 3,
                                    restrictions_exact = list("3"=0, "3.67" = 2),
                                    restrictions_minimum = "range")
find_possible_distribution(sprite_parameters)
#> $outcome
#> [1] "success"
#> 
#> $values
#>  [1] 5.000000 1.000000 1.000000 1.000000 1.000000 1.666667 1.000000 2.000000
#>  [9] 1.000000 1.000000 5.000000 1.000000 1.000000 1.000000 1.000000 1.000000
#> [17] 1.000000 5.000000 3.666667 3.666667
#> 
#> $mean
#> [1] 1.95
#> 
#> $sd
#> [1] 1.549476
#> 
#> $iterations
#> [1] 90
#>