rcpd: Sampler for the CPD Block Model

View source: R/rcpd.R

rcpdR Documentation

Sampler for the CPD Block Model

Description

Creates a nrow \times ncol matrix with ncp change points. In between change points, the random variables are i.i.d. sampled from the given family and parameters

Usage

rcpd(
  nrow = 100,
  ncol = 50,
  ncp = 1,
  family = "bernoulli",
  parameters = NULL,
  changepoints = NULL,
  prob_NA = 0
)

Arguments

nrow

Number of rows, or sample size, of the data.

ncol

Number of columns of data matrix. It is the number of variables for each sample.

ncp

Number of change points. The number of blocks is ncp + 1. It is overridden if changepoints is non-NULL.

family

The family model to be sampled. The families currently implemented are:

  • bernoulli: Sample independent Bernoullis with probability parameter of the block

  • normal: Sample independent Normal with mean and variance specified by the block.

  • binaryMarkov: Samples a two state Markov Chain process with transition matrix defined by the block.

  • exponential: Sample independent Exponential with scale parameter defined by the block.

  • poisson: Sample independent Poisson with rate parameter defined by the block.

parameters

List of parameters containing ncp + 1 dimensional parameter vectors of each block. If NULL, the parameters are sampled randomly.

changepoints

A sorted vector of size ncp containing integers as change point locations. The change points are between 1 and ncol-1. If NULL, the change points are sampled uniformly in [1, ncol-1].

prob_NA

Probability of each entry of being NA. Default is 0.

Value

Returns a list containing 3 elements: #'

  • "data_matrix" A matrix containing the data.

  • "changepoints" A numeric vector containing the change-point locations

  • "parameters" A list whose keys are the parameters names and the values are vectors containing the parameter for each block.

Examples

td = rcpd(nrow = 20, ncol = 10) # 20 Bernoulli series of size 10 with 1 change-point
td = rcpd(nrow = 10, ncol = 100, ncp = 5,
          family = "normal") # 10 normal series of size 100 with 5 change-points
td = rcpd(nrow = 1000, ncol = 100, changepoints = c(10, 40, 79)) # choosing change-points locations
td = rcpd(nrow = 100, ncol = 15, ncp = 2, family = "normal",
          parameters = list(mean = c(1, 2, 3), var = c(4, 5, 6))) # choosing parameters

Lucas-Prates/blockcpd documentation built on Aug. 19, 2022, 12:55 a.m.