# set_uniform_cd: Set a uniform change distribution. In Tveten/tpca: A function for tailoring PCA to change detection

## Description

This function is used to specify a change distribution to be used in conjuction with the function `tpca`. All components of the distribution (marginal and conditional distributions) are uniform, but the probability/importance of each type of change can be specified, along with the range of sparsity of the change, as well as ranges for the sizes and directions of the different change types. In each simulation run, after a change sparsity has been drawn, which dimensions that are affected by a change is always randomized. Choices for the distribution should reflect prior knowledge about which changes that are of interest to detect.

## Usage

 ```1 2 3``` ```set_uniform_cd(data_dim, prob = rep(1/3, 3), sparsities = 2:data_dim, mean_int = c(-1.5, 1.5), sd_int = c(2.5^(-1), 2.5), sd_inc_prob = 0.5, cor_int = c(0, 1), change_equal = FALSE) ```

## Arguments

 `data_dim` An integer specifying the dimension of the data. `prob` A numeric vector of length 3 specifying the probability of a change in the mean, variance or correlation, respectively. `sparsities` An integer vector containing values between 2 (minimum sparsity for changes in the correlation) and data_dim. `mean_int` A vector of length 2 specifying the lower and upper bound of the interval that changes in the mean components are drawn uniformly from. `sd_int` A vector of length 2 specifying the lower and upper bound of the interval that multiplicative changes in the standard deviations are drawn from. Must be between ε and ε^{-1}, where ε = `sqrt(.Machine\$double.eps)`. `sd_inc_prob` A numeric between 0 and 1 indicating the probability of a change in the standard deviation being an increase. `cor_int` A vector of length 2 specifying the lower and upper bound of the interval that multiplicative changes in the correlations are drawn from. Only values between 0 and 1 are allowed, i.e. a jump towards 0 of the correlation coefficients. `change_equal` A logical for whether all affected dimensions should change by the same amount, or by amounts independent of eachother. For example, if TRUE and the mean changes, μ_d = μ for all d in D, where D is the set of affected dims.

See references.

## Value

`set_uniform_cd` returns an S3 object of class "change_distr". This is a list containing the following functions:

`draw_types(n_sim)`

A function that draws `n_sim` change types among ('mean', 'sd', 'cor') with probabilities `prob`.

`draw_sparsities(n_sim)`

A function that draws `n_sim` change sparsities uniformly from `sparsities`.

`draw_dims(k)`

A function that uniformly draws a size k subset of affected dimensions.

`draw_mean(k)`

A function that draws k values uniformly from `mean_int`.

`draw_sd(k)`

A function that draws an increase in the standard deviation uniformly from [0, `sd_int`] with probability `sd_inc_prob`, and a decrease in standard deviation uniformly from [`sd_int`, 1] with probability 1 - `sd_inc_prob`.

`draw_cor(k)`

A function that draws k values uniformly from `cor_int`

The functions with argument `n_sim` are called with the number of simulations as arguments, while the ones with argument `k` are called in each simulation run with a number depending on the change sparsity.

Tveten/tpca documentation built on June 10, 2021, 8:43 p.m.