get_noisy_weights {COINr}R Documentation

Noisy replications of weights


Given a data frame of weights, this function returns multiple replicates of the weights, with added noise. This is intended for use in uncertainty and sensitivity analysis.


get_noisy_weights(w, noise_specs, Nrep)



A data frame of weights, in the format found in .$Meta$Weights.


a data frame with columns:

  • Level: The aggregation level to apply noise to

  • NoiseFactor: The size of the perturbation: setting e.g. 0.2 perturbs by +/- 20% of nominal values.


The number of weight replications to generate.


Weights are expected to be in a data frame format with columns Level, iCode and Weight, as used in iMeta. Note that no NAs are allowed anywhere in the data frame.

Noise is added using the noise_specs argument, which is specified by a data frame with columns Level and NoiseFactor. The aggregation level refers to number of the aggregation level to target while the NoiseFactor refers to the size of the perturbation. If e.g. a row is Level = 1 and NoiseFactor = 0.2, this will allow the weights in aggregation level 1 to deviate by +/- 20% of their nominal values (the values in w).

This function replaces the now-defunct noisyWeights() from COINr < v1.0.


A list of Nrep sets of weights (data frames).

See Also


# build example coin
coin <- build_example_coin(up_to = "new_coin", quietly = TRUE)

# get nominal weights
w_nom <- coin$Meta$Weights$Original

# build data frame specifying the levels to apply the noise at
# here we vary at levels 2 and 3
noise_specs = data.frame(Level = c(2,3),
                         NoiseFactor = c(0.25, 0.25))

# get 100 replications
noisy_wts <- get_noisy_weights(w = w_nom, noise_specs = noise_specs, Nrep = 100)

# examine one of the noisy weight sets, last few rows

[Package COINr version 1.1.7 Index]