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), an integer of at least two for reconstruction.

min_val

The minimum value

max_val

The maximum value

m_prec

The precision of the reported mean, as a nonnegative integer number of decimal places (at most 308), consistent with the supplied value. Inferred from the numeric value if omitted; specify it explicitly when the reported mean ends in zero.

sd_prec

The precision of the reported standard deviation, with the same requirements as m_prec. Specify it explicitly to preserve trailing zeroes.

n_items

Positive integer 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. This skips GRIM, GRIMMER, and SD-bound checks; input validation and restriction checks still apply.

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, for multi-item scales, name the response as precisely as needed to identify it. Exact lattice matches take priority; rounded names are also accepted if they identify a unique response (e.g., list("1.67" = 0) when n_items = 3). Ambiguous shorthand and duplicate restrictions are rejected. Counts must be nonnegative integers, with their sum no greater than n_obs.

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] 1
#> 

# 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] 1.333333 1.333333 5.000000 1.000000 1.000000 5.000000 1.000000 1.000000
#>  [9] 1.000000 1.000000 2.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.545698
#> 
#> $iterations
#> [1] 60
#>